try this

Code:
'keyTxt is the encryption key
'if you set directionTxt to "1" it will decrypt ... if it's set to 
'anything else, it will encrypt ... (I know it's odd using a 
'String as the direction variable, but I used this in an ASP page
'and was passing in the direction via QueryString 
iSeed=0
For i=1 To Len(keyTxt)
    iSeed=iSeed + Asc(Mid(keyTxt, i, 1))
Next
Randomize(iSeed)
decrypt=""
		
For i=1 To Len(messageTxt)
    if (directionTxt ="1") then
        decrypt = decrypt & Chr((Asc(Mid(messageTxt, i, 1)) + (Int(Rnd() * 10))))
    else
        decrypt = decrypt & Chr((Asc(Mid(messageTxt, i, 1)) - (Int(Rnd() * 10))))
    End If
Next
hope this helps ...