Simple Encryption

a very simple ASCII encryption.. comes handy at times..

Public Function SimpleCrypt(ByVal Text As String) As String
  ' Encrypts/decrypts the passed string using
  ' a simple ASCII value-swapping algorithm
  Dim strTempChar As String, i As Integer
  For i = 1 To Len(Text)
    If Asc(Mid$(Text, i, 1))  128 Then
      strTempChar = CType(Asc(Mid$(Text, i, 1)) - 128, String)
    End If
    Mid$(Text, i, 1) = Chr(CType(strTempChar, Integer))
  Next i
  Return Text
End Function


Dim MyText As String
' Encrypt
MyText = "Hello World"
MyText = SimpleCrypt(MyText)
' Decrypt
MyText = SimpleCrypt(MyText)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s