Sunday 21 April 2013

How to encrypt password with hashing( Algorithm)

Hi guys once again with some new stuff only for my dear readers
I have written an algorithm that encrypt and chop the password. Use these function before saving the password to the database and whenever you want to match the password with the password which is entered by user you can call this function there again and by retrieving the saved password you can run comparison. THE CODE IS WRITTEN IN VB.NET AND CHECKED ON VISUAL STUDIO 2008 
This function accept password as String and return encrypted and chopped password ....
This code is now public but you can still use this code because even having the algorithm one can not get original password.

Public Function encrypt(ByVal psd As String) As String
        Dim count As Integer
        Dim charcarr(3) As Char
        count = psd.Length
        Dim chariarr(count) As Integer
        Dim i As Integer = 0
        For Each element As Char In psd
            chariarr(i) = Asc(element) + 3
            i = i + 1
        Next
        If count <= 2 Then
            i = 1
            ReDim charcarr(count)

            For h As Integer = 0 To count - 1
                charcarr(h) = Chr(chariarr(h))
            Next

        Else
            i = i / 2
            i = i - 1

            For j As Integer = 0 To 2
                charcarr(j) = Chr(chariarr(i))
                i = i + 1
            Next
        End If

        psd = New String(charcarr)
        Return psd
    End Function

GUYS YOUR COMMENTS ARE SO VALUABLE SO PLEASE GIVE YOUR FEEDBACK

No comments:

Post a Comment