• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

Visual Basic RC4 Encryption in VB

Status
Not open for further replies.

Kaway

Banned
User
Joined
Aug 7, 2014
Messages
720
Reputation
0
Reaction score
5,766
Points
243
Credits
0
‎10 Years of Service‎
15%
Please note, if you want to make a deal with this user, that it is blocked.
[HIDE-THANKS]RC4 is a stream cipher designed by Rivest for RSA Security. Here is a RC4-encryption function for VB. Just copy and paste into your project. Enjoy!

Code:
>  Public Function RC4(ByVal Expression As String, ByVal Password As String) As String
On Error Resume Next
Dim RB(0 To 255) As Integer, X As Long, Y As Long, Z As Long, Key() As Byte, ByteArray() As Byte, Temp As Byte
If Len(Password) = 0 Then
   Exit Function
End If
If Len(Expression) = 0 Then
   Exit Function
End If
If Len(Password) > 256 Then
   Key() = StrConv(Left$(Password, 256), vbFromUnicode)
Else
   Key() = StrConv(Password, vbFromUnicode)
End If
For X = 0 To 255
   RB(X) = X
Next X
X = 0
Y = 0
Z = 0
For X = 0 To 255
   Y = (Y + RB(X) + Key(X Mod Len(Password))) Mod 256
   Temp = RB(X)
   RB(X) = RB(Y)
   RB(Y) = Temp
Next X
X = 0
Y = 0
Z = 0
ByteArray() = StrConv(Expression, vbFromUnicode)
For X = 0 To Len(Expression)
   Y = (Y + 1) Mod 256
   Z = (Z + RB(Y)) Mod 256
   Temp = RB(Y)
   RB(Y) = RB(Z)
   RB(Z) = Temp
   ByteArray(X) = ByteArray(X) Xor (RB((RB(Y) + RB(Z)) Mod 256))
Next X
RC4 = StrConv(ByteArray, vbUnicode)
End Function
[/HIDE-THANKS]
 
Status
Not open for further replies.
Back
Top