Sorry for untidy code, yet I used it for a specific task of en/decrypting longs.
Public Shared Function Encode(ByVal cnum As Long) As String
Dim i0 As Long
Dim e As Long
Dim tcnum As Long
Dim pos As Integer, a As Integer
Dim str As String
Dim i As Integer
Randomize()
i0 = CInt(Int(26 * Rnd()))
str = Chr(Asc("A") + i0)
e = 29
tcnum = cnum Xor &H55555555
pos = i0
For i = 0 To 7
a = tcnum Mod 16
pos = (pos + a * e) Mod 26
str &= Chr(Asc("A") + pos)
tcnum = Int(tcnum / 16)
Next
Return str
End Function
Public Shared Function Decode(ByVal str As String) As Long
Dim i As Integer
Dim tcnum As Long
Dim a As Integer
tcnum = 0
For i = str.Length - 1 To 1 Step -1
tcnum *= 16
a = (Asc(str.Chars(i)) - Asc(str.Chars(i - 1)) + 26) Mod 26
a = (a + (a Mod 3) * 26) / 3
tcnum += a
Next i
Return (tcnum Xor &H55555555)
End Function
--
Best regards,
Andrew P. Revinsky
"Jason Shohet" wrote:
i downloaded it but can't seem to find the encryption class file :) In fact
i don't see any dll's, or .cs files, just .pas & .dpk files, whatever those
are.
Not sure how to use that in my asp.net / c# codebehind environment
TY