Attribute VB_Name = "modEncryption" Option Explicit Public Function Crypt(Action As String, Key As String, Src As String) As String 'E encrypts, D decrypts, Key is a unique string needed to en/decrypt '(either hardcode or 'setup something for the user to enter. Src is the string to be en/decrypted. Dim count As Integer, KeyPos As Integer, KeyLen As Integer, SrcAsc As Integer Dim Dest As String, Offset As Integer, TmpSrcAsc, SrcPos As Integer Const KN_OFFSET = 91 KeyLen = Len(Key) If Action = "E" Then 'Randomize 'Offset = (Rnd * 10000 Mod 255) + 1 'Modified by randy gadingan Offset = KN_OFFSET Dest = Hex$(Offset) For SrcPos = 1 To Len(Src) SrcAsc = (Asc(Mid$(Src, SrcPos, 1)) + Offset) Mod 255 If KeyPos < KeyLen Then KeyPos = KeyPos + 1 Else KeyPos = 1 'Fill Dest$ with HEX representation of Encrypted field 'Hex used to keep nasties such as eof or lf from mangling stream 'Use format$ to make Hex$ return " 0" instead of "0" when the same 'values are Xor'ed together (Null) - keeps placeholder for decrypt SrcAsc = SrcAsc Xor Asc(Mid$(Key, KeyPos, 1)) Dest = Dest + Format$(Hex$(SrcAsc), "@@") Offset = SrcAsc Next ElseIf Action = "D" Then Offset = Val("&H" + Left$(Src, 2)) For SrcPos = 3 To Len(Src) Step 2 SrcAsc = Val("&H" + Trim(Mid$(Src, SrcPos, 2))) If KeyPos < KeyLen Then KeyPos = KeyPos + 1 Else KeyPos = 1 TmpSrcAsc = SrcAsc Xor Asc(Mid$(Key, KeyPos, 1)) If TmpSrcAsc <= Offset Then TmpSrcAsc = 255 + TmpSrcAsc - Offset Else TmpSrcAsc = TmpSrcAsc - Offset End If Dest = Dest + Chr(TmpSrcAsc) Offset = SrcAsc Next End If Crypt = Dest End Function