May 2012
MTWTFSS
«Mar  
 123456
78910111213
14151617181920
21222324252627
28293031 

Enkripsi RC4 part 2

Part 2 berisi contoh source code enkripsi menggunakan PowerBuilder. Silahkan mencoba dengan sedikit berkreasi.

function f_rc4(string:as_plaintext,string:as_key) return string

integer i,j,temp,y,ll_len1,b,p,z
char m
int s[256],k[256],ll_key[]
string ls_result
j = 1

ll_len1 = len(as_key)
for i = ll_len1 to 1 step -1
ll_key[i] = asc( mid(as_key,i,1) )
next

for i = 1 to 256

s[i]=i
if j = ll_len1 + 1 then j = 1
k[i] = ll_key[j]
j++

next

j=1
i=1
for i = 1 to 256

j = s[i] + k[i]
j = mod(j,256) + 1
temp = s[i]
s[i] = s[j]
s[j] = temp

next

i = 1
j = 1
for b = 1 to len(as_plaintext)

i = mod(i,256) + 1
j = mod((j + S[i]),256) + 1
temp = s[i]
s[i] = s[j]
s[j] = temp
temp = mod((s[i] +s[j]),256) + 1
y = s[temp]
p = asc( mid(as_plaintext,b,1) )
z = 256 + y –p
m = char(z)
ls_result = ls_result + m

next

return ls_result

Inlinks:

Leave a Reply

  

  

  

You can use these HTML tags

<a href=""title=""><abbr title=""><acronym title=""><b><blockquote cite=""><cite><code><del datetime=""><em><i><q cite=""><strike><strong>