Sandy,
sorry but I don't uderstand the meaning of the loop.
I rearranged your script in order to make simple encryption/decryption using the a key created by the Hash() function.
uses "crypto"
Dim sPlainTxt as string = "This is the plain text that contains some U.S. president's secrets!" ' Example of test to encrypt
dim sUserName as string = "George W Bush" ' Example user name
dim sPassword as string = "MyPassword" ' Example password
dim sHash as string ' Hash string
dim sDarkTxt as string ' Encrypted string
dim sTxt as string ' Back to plain text
sHash = str$(hash(1, sUserName + sPassword)) ' Create a hash string
msgbox 0, "The hash string is" + sHash ' Show the hash string
sDarkTxt = iCrypto_DecryptRC4(sPlainTxt, sHash) ' Encrypt secret data
msgbox 0, "This is the encrypted (dark) text:" + $crlf + "<text>" + sDarkTxt + "</text>" 'Show the encrypted data
sTxt = iCrypto_DecryptRC4(sDarkTxt, sHash) ' Decrypt secret data
msgbox 0, "This is the decrypted (plain) text:" + $crlf + "<text>" + sTxt + "</text>" ' Show the decrypted data
' Lazy men error checking!
if sPlainTxt = sTxt then
msgbox 0, "Ok strigs are equals:"+ $crlf + "<text>" + sPlainTxt + "</text>" + $crlf + "<text>" + sTxt + "</text>"
else
MSGBOX 0, "Error!"
end if
Ciao,
Roberto
Bookmarks