04.28

Function Encrypt & Decrypt

[function string of_encrypt(as_str)]
integer i, j
string ls_enctext = ""
CONSTANT string CRYPT_KEY = "$#@%&#%@&*"

j = len(as_str)
FOR i = 1 TO j
ls_enctext += mid(CRYPT_KEY , mod(i,10) + 1, 1)
ls_enctext += String(Char(255 - Asc(Mid(as_str, i, 1))))
NEXT

RETURN ls_enctext
======================================================
[function string of_decrypt(as_str)]
integer i, j
string ls_encchar, ls_temp, ls_unasstr = "** Encryption Error"
boolean lb_ok = true
CONSTANT string CRYPT_KEY = "$#@%&#%@&*"

j = len(as_str)

IF NOT Mod(j, 2) = 1 THEN
ls_temp = ""
FOR i = 2 TO (j + 1) STEP 2
ls_encchar = Mid(as_str, i - 1, 1)
IF mid(CRYPT_KEY, Mod(i / 2, 10) + 1, 1) <> ls_encchar THEN
lb_ok = FALSE
EXIT
END IF
ls_encchar = Mid(as_str, i, 1)
ls_temp += string(char(255 - asc(ls_encchar)))
NEXT
END IF

IF lb_ok THEN ls_unasstr = ls_temp

RETURN LS_UNASSTR
=======================================================

1 komentar:

hagi mengatakan...

waduuuhh man...blog loe bakalan rame man...
jgn lupa counter nya man..

Posting Komentar