Enc & Dec text for Security

Downloads:740 Bookmark this code Bookmark and Share
Rank : 1/5
Rated by : 1 user(s)
Developer:Bilal Yousaf  |   5 submission(s)
Date Uploaded:November 13,2007
Level:Advanced
Size: 0 Bytes
Category:VB.Net -> Encryption/Security
Developer Says:

to enc and Dec Text for Security Purpose like as password or login informaton etc

#Region "Encryption decryption"
 
    Dim sbox(255)
    Dim key(255)
 
    Sub RC4Initialize(ByVal strPwd As String)
        ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        ':::  This routine called by EnDeCrypt function. Initializes the :::
        ':::  sbox and the key array)                                    :::
        ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
        Dim tempSwap
        Dim a
        Dim b, intLength
 
        intLength = Len(strPwd)
        For a = 0 To 255
            key(a) = Asc(Mid(strPwd, (a Mod intLength) + 1, 1))
            sbox(a) = a
        Next
 
        b = 0
        For a = 0 To 255
            b = (b + sbox(a) + key(a)) Mod 256
            tempSwap = sbox(a)
            sbox(a) = sbox(b)
            sbox(b) = tempSwap
        Next
 
    End Sub
 
    Function EnDeCrypt(ByVal plaintxt As String) As String
        ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        ':::  This routine does all the work. Call it both to ENcrypt    :::
        ':::  and to DEcrypt your data.                                  :::
        ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
        Dim temp
        Dim a
        Dim i
        Dim j
        Dim k
        Dim cipherby
        Dim cipher, psw
 
        i = 0
        j = 0
 
        psw = "encdecpassword"
        RC4Initialize(psw)
 
        For a = 1 To Len(plaintxt)
            i = (i + 1) Mod 256
            j = (j + sbox(i)) Mod 256
            temp = sbox(i)
            sbox(i) = sbox(j)
            sbox(j) = temp
 
            k = sbox((sbox(i) + sbox(j)) Mod 256)
 
            cipherby = Asc(Mid(plaintxt, a, 1)) Xor k
            cipher = cipher & Chr(cipherby)
        Next
 
        EnDeCrypt = cipher
 
    End Function
 
#End Region

The above code was highlighted with Neat Highlighter


User Reviews
There are no user reviews on this code
Leave a Comment
Age (Required, will not be shown)
Name
Email (Required, will not be shown)
Website (Optional, starting with http://)
 
Rate this code
Poor   1 2 3 4 5   Outstanding
Are you human ?

Enter the code shown above