VB version RC4 algorithm
Public Sub Main ()
Dim Key as String
For i = 1 to 16
Randomize
Key = key & Chr (RND * 255)
Next I
MsgBox RC4 (RC4 ("Welcome to Plindge studio!", key)
End Sub
Public Function RC4 (INP As String, key as String) as String
Dim S (0 to 255) as Byte, K (0 to 255) as Byte, I as Long
Dim J as long, temp as Byte, Y as Byte, t as Long, X as Long
Dim OUTP as String
For i = 0 to 255
S (i) = i
Next
j = 1
For i = 0 to 255
If J > Len (key) Then j = 1
K (i) = ASC (Mid (Key, J, 1))
j = j + 1
Next I
j = 0
For i = 0 to 255
j = (j + S (i) + K (i)) Mod 256
temp = S (i)
S (i) = S (j)
S (j) = Temp
Next I
i = 0
j = 0
For x = 1 to Len (INP)
i = (i + 1) Mod 256
j = (j + S (i)) Mod 256
temp = S (i)
S (i) = S (j)
S (j) = Temp
T = (s (i) + (s (j) mod 256)) Mod 256
Y = S (t)
OUTP = OUTP & Chr (ASC (Mid (INP, X, 1)) Xor Y)
Next
RC4 = OUTP
End Function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service