ProtectText + UnProtectText

Encrypt or decrypt text, simple encryption with a numeric password
Decrypt a string, convert it to "77 96 105 105 106 "

Function UnProtectText(sText, iPwd)
 ' Pwd is a numeric password = Enc = Encrypt number
 Dim NewStr, Enc, OldI
 Enc = iPwd ' 5
 NewStr = "": OldI = 1
 For I = 1 To Len(sText)
  mimi = Mid(sText, I, 1)
  If mimi = " " Then
   mimi = Mid(sText, OldI, I - OldI)
   NewStr = NewStr & Chr(Val(mimi) Xor Enc)
   OldI = I
  End If
 Next I
 UnProtectText = NewStr
End Function
Function ProtectText(sText, iPwd)
 ' Encrypt a string and convert it from "77 96 105 105 106 "
 ' Pwd is a numeric password/key = Enc = Encrypt number
 Dim NewStr, Enc
 Enc = iPwd ' 5
 NewStr = ""
 For I = 1 To Len(sText)
  mimi = Mid(sText, I, 1)
  NewStr = NewStr & Str(Asc(mimi) Xor Enc)
 Next I
 ProtectText = NewStr
End Function

sText, iPwd

Views 674 Downloads 236

'ProtectText', 'UnProtectText', 'Encrypt', 'Decrypt', 'protection'

ANmarAmdeen
326
Protection Classic ASP
Revisions

v1.0