Public Function subEncrypt(textToEncrypt As String)
'sub to encrypt letters
Dim a(1 To 30) As String, encryptedText As String, scrambledText As String
Dim textLength As Integer, x As Integer, y As Integer
Dim tmp1 As String, tmp2 As String, tmp3 As String, tmp4 As String, tmp5 As String, tmp6 As String, tmp7 As String, tmp8 As String
'assign textlength length of texttoencrypt
textLength = Len(textToEncrypt)
'for/next to go through each letter in texttoencrypt
For x = 1 To textLength
a(x) = Mid(textToEncrypt, x, 1)
Select Case a(x)
Case Is = "A"
a(x) = "-"
Case Is = "B"
a(x) = ")"
Case Is = "C"
a(x) = "?"
Case Is = "D"
a(x) = "#"
Case Is = "E"
a(x) = "<"
Case Is = "F"
a(x) = "6"
Case Is = "G"
a(x) = "b"
Case Is = "H"
a(x) = "Z"
Case Is = "I"
a(x) = "="
Case Is = "J"
a(x) = "8"
Case Is = "K"
a(x) = "p"
Case Is = "L"
a(x) = "a"
Case Is = "M"
a(x) = "9"
Case Is = "N"
a(x) = ">"
Case Is = "O"
a(x) = "}"
Case Is = "P"
a(x) = "2"
Case Is = "Q"
a(x) = "4"
Case Is = "R"
a(x) = "1"
Case Is = "S"
a(x) = "v"
Case Is = "T"
a(x) = "."
Case Is = "U"
a(x) = "3"
Case Is = "V"
a(x) = "l"
Case Is = "W"
a(x) = "B"
Case Is = "X"
a(x) = "\"
Case Is = "Y"
a(x) = "T"
Case Is = "Z"
a(x) = "h"
Case Is = "0"
a(x) = "e"
Case Is = "1"
a(x) = ";"
Case Is = "2"
a(x) = "k"
Case Is = "3"
a(x) = "!"
Case Is = "4"
a(x) = "$"
Case Is = "5"
a(x) = "@"
Case Is = "6"
a(x) = "/"
Case Is = "7"
a(x) = "+"
Case Is = "8"
a(x) = "G"
Case Is = "9"
a(x) = ":"
Case Is = "["
a(x) = "%"
Case Is = "]"
a(x) = "("
Case Is = "*"
a(x) = "^"
Case Is = " "
a(x) = "_"
Case Is = "'"
a(x) = "S"
Case Is = "#"
a(x) = "x"
End Select
'put encrypted letters into encryptedtext
encryptedText = encryptedText & a(x)
Next x
'assign first 4 letters & last 4 letters
tmp1 = a(1)
tmp2 = a(2)
tmp3 = a(3)
tmp4 = a(4)
tmp5 = a(textLength - 1)
tmp6 = a(textLength - 2)
tmp7 = a(textLength - 3)
tmp8 = a(textLength)
'scramble (switch) letters
a(1) = tmp3
a(2) = tmp6
a(3) = tmp1
a(4) = tmp8
a(textLength - 1) = tmp7
a(textLength - 2) = tmp2
a(textLength - 3) = tmp5
a(textLength) = tmp4
'put scrambled letters back into text
For y = 1 To textLength
scrambledText = scrambledText & a(y)
Next y
'make sure function returns final encrypted & scrambled text
subEncrypt = scrambledText
End Function
'/////////////////////////
Public Function subDecrypt(textToDecrypt As String)
'sub to decrypt text file
Dim a(1 To 30) As String, decryptedText As String, unscrambledText As String
Dim textLength As Integer, x As Integer, y As Integer
Dim tmp1 As String, tmp2 As String, tmp3 As String, tmp4 As String, tmp5 As String, tmp6 As String, tmp7 As String, tmp8 As String
'assign textlength length of texttodecrypt
textLength = Len(textToDecrypt)
'for/next to go through each letter in texttodecrypt
For x = 1 To textLength
a(x) = Mid(textToDecrypt, x, 1)
'decrypt letters
Select Case a(x)
Case Is = "-"
a(x) = "A"
Case Is = ")"
a(x) = "B"
Case Is = "?"
a(x) = "C"
Case Is = "#"
a(x) = "D"
Case Is = "<"
a(x) = "E"
Case Is = "6"
a(x) = "F"
Case Is = "b"
a(x) = "G"
Case Is = "Z"
a(x) = "H"
Case Is = "="
a(x) = "I"
Case Is = "8"
a(x) = "J"
Case Is = "p"
a(x) = "K"
Case Is = "a"
a(x) = "L"
Case Is = "9"
a(x) = "M"
Case Is = ">"
a(x) = "N"
Case Is = "}"
a(x) = "O"
Case Is = "2"
a(x) = "P"
Case Is = "4"
a(x) = "Q"
Case Is = "1"
a(x) = "R"
Case Is = "v"
a(x) = "S"
Case Is = "."
a(x) = "T"
Case Is = "3"
a(x) = "U"
Case Is = "l"
a(x) = "V"
Case Is = "B"
a(x) = "W"
Case Is = "\"
a(x) = "X"
Case Is = "T"
a(x) = "Y"
Case Is = "h"
a(x) = "Z"
Case Is = "e"
a(x) = "0"
Case Is = ";"
a(x) = "1"
Case Is = "k"
a(x) = "2"
Case Is = "!"
a(x) = "3"
Case Is = "$"
a(x) = "4"
Case Is = "@"
a(x) = "5"
Case Is = "/"
a(x) = "6"
Case Is = "+"
a(x) = "7"
Case Is = "G"
a(x) = "8"
Case Is = ":"
a(x) = "9"
Case Is = "%"
a(x) = "["
Case Is = "("
a(x) = "]"
Case Is = "^"
a(x) = "*"
Case Is = "_"
a(x) = " "
Case Is = "S"
a(x) = "'"
Case Is = "x"
a(x) = "#"
End Select
'put decrypted letters in decryptedtext
decryptedText = decryptedText & a(x)
Next x
'assign first 4 letters & last 4 letters
tmp1 = a(1)
tmp2 = a(2)
tmp3 = a(3)
tmp4 = a(4)
tmp5 = a(textLength - 1)
tmp6 = a(textLength - 2)
tmp7 = a(textLength - 3)
tmp8 = a(textLength)
'scramble (switch) letters
a(1) = tmp3
a(2) = tmp6
a(3) = tmp1
a(4) = tmp8
a(textLength - 1) = tmp7
a(textLength - 2) = tmp2
a(textLength - 3) = tmp5
a(textLength) = tmp4
'put unscrambled letters back into text
For y = 1 To textLength
unscrambledText = unscrambledText & a(y)
Next y
'make sure function returns final decrypted & unscrambled text
subDecrypt = unscrambledText
End Function