by Damage.Case (3 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 10th February 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This is an example of REAL encryption. Not that ASCII addition/subtraction junk.
'call them yourself.
'This is how encryption is done boys and girls.
'I'm sick of seeing posts of encryption routines
'that add and subtract to the ascii number of a
'character. It's very ineffective. Decryption
'programs can crack simple stuff like that in
'less than a second. Do it right.
'Note: Don't make the key repetative in any way!
Option Explicit
Private Function Decrypt(PlainStr As String, key As String)
Dim Char As String, KeyChar As String, NewStr As String
Dim Pos As Integer
Dim i As Integer, Side1 As String, Side2 As String
Pos = 1
'This is a little trick to make it slightly harder to crack.
'However, the chances of this operation firing is 50/50
'because the length of the string must be divisable by 2.
If Len(PlainStr) Mod 2 = 0 Then
Side1 = StrReverse(Left(PlainStr, (Len(PlainStr) / 2)))
Side2 = StrReverse(Right(PlainStr, (Len(PlainStr) / 2)))
PlainStr = Side1 & Side2
End If
'This loop decrypts the data.
For i = 1 To Len(PlainStr)
Char = Mid(PlainStr, i, 1)
KeyChar = Mid(key, Pos, 1)
NewStr = NewStr & Chr(Asc(Char) Xor Asc(KeyChar))
If Pos = Len(key) Then Pos = 0
Pos = Pos + 1
Next i
Decrypt = NewStr
End Function
Private Function Encrypt(PlainStr As String, key As String)
Dim Char As String, KeyChar As String, NewStr As String
Dim Pos As Integer
Dim i As Integer, Side1 As String, Side2 As String
Pos = 1
'This loop encrypts the data.
For i = 1 To Len(PlainStr)
Char = Mid(PlainStr, i, 1)
KeyChar = Mid(key, Pos, 1)
NewStr = NewStr & Chr(Asc(Char) Xor Asc(KeyChar))
If Pos = Len(key) Then Pos = 0
Pos = Pos + 1
Next i
'This is a little trick to make it slightly harder to crack.
'However, the chances of this operation firing is 50/50
'because the length of the string must be divisable by 2.
If Len(NewStr) Mod 2 = 0 Then
Side1 = StrReverse(Left(NewStr, (Len(NewStr) / 2)))
Side2 = StrReverse(Right(NewStr, (Len(NewStr) / 2)))
NewStr = Side1 & Side2
End If
Encrypt = NewStr
End Function
No comments have been posted about This is an example of REAL encryption. Not that ASCII addition/subtraction junk.. Why not be the first to post a comment about This is an example of REAL encryption. Not that ASCII addition/subtraction junk..