by MHari (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 29th November 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Encrypt or Decrypt String
API Declarations
'Pass the string to this function it returns the encrypted string in ascii codes
'Encryption function
Function StrEncode(ByVal s As String) As String
Dim a
b = ""
i = 1
a = s
Do While i < Len(a) + 1
b = b & (Asc(Mid(a, i, Len(a))) * 8)
i = i + 1
Loop
StrEncode = b
End Function
'Pass the encrypted string to this function it returns the decrypted string
'Decryption function
Function StrDecode(ByVal s As String) As String
Dim c As String
Dim p As Integer
j = 1
c = ""
b = s
Do While j < Len(b) + 1
p = Val(Mid(b, j, 3)) / 8
c = c & Chr(p)
j = j + 3
Loop
StrDecode = c
End Function