Here is my translation so far of what I have
into Visual Basic .NET)
#Region "ZPFEncrypt"
Public Shared Function ZPFEncryptString(ByVal key As String, ByVal text As String)
If key = text Then
Return ("")
End If
Dim encrypt, replace, add, newadd, reverse As String
Dim keyletter, areplace, rand, t, x As Integer
encrypt = ""
KeyLetter = 1
For t = 1 To Len(text)
replace = Mid(text, 1)
With .s = Mid(key, KeyLetter, 1)
AReplace=Asc(Replace)+Asc(With)+Len(Key)
Repeat()
If AReplace < 0 Then
AReplace = 255 + AReplace
ElseIf AReplace > 255 Then
AReplace = AReplace
Else
Endit = 1
End If
End With
Until Endit=1
encrypt = encrypt + Chr(areplace)
keyletter = keyletter + 1
If keyletter > Len(key) Then
keyletter = 1
End If
Next t
For x = Len(text) To 1 Step -1
reverse = reverse + Mid(encrypt, x, 1)
Next x
encrypt = reverse$
;New
rand = Rnd(Len(text) - 1) + 1
add = Mid(encrypt, 1, Rnd)
For t = 1 To Len(Add)
newadd = newadd + Chr(Asc(Mid(add, t, 1)) + Rnd(33) + 10)
Next t
rand = Len(NewAdd)
encrypt = Str(Rnd) + encrypt
encrypt = encrypt + newadd
Return (encrypt)
End Function
#End Region
#Region "ZPFDecrypt"
Public Shared Function ZPFDecryptString(ByVal Key As String, ByVal text As String)
Dim decrypt, forward, replace As String
Dim rand, keyletter, y, areplace, t As Integer
decrypt = ""
;New
rand = Val(Mid(text, 1, 1))
text = Mid(text, 2, Len(text))
text = Mid(text, 1, Len(text) - Rnd())
For y = Len(text) To 1 Step -1
forward = forward + Mid(text, y, 1)
Next y
text = forward$
If Key = text Then
Return ("")
End If
KeyLetter = 1
For t = 1 To Len(text)
Replace = Mid(text, t, 1)
With .s = Mid(Key, KeyLetter, 1)
AReplace=Asc(Replace)-Asc(With)-Len(Key)
Repeat()
If AReplace < 0 Then
AReplace = 255 + AReplace
ElseIf AReplace > 255 Then
AReplace = AReplace
Else
Endit = 1
End If
Until Endit=1
decrypt = decrypt + Chr(areplace)
keyletter = keyletter + 1
If KeyLetter > Len(Key) Then
KeyLetter = 1
End If
Next t
Return (decrypt)
End Function
#End Region
The following parts I do not understand:
>With .s
>asc(with)
>repeat()
>endit
>;New
If you would mind giving me an idea of how those commands are suppose to work, it would help very much in translating your code to VB.NET(2003).
Regards,
1tg46
And to show my appreciation for posting the code here are two examples [in VB.NET] of two other encryption algorithms.
#Region "Rail_Fence_2line_Encrypt"
Public Shared Function Rail_Fence_2line_Encrypt(ByVal text As String) As String
Dim b As Double = text.Length / 4
If b.ToString.IndexOf(".") = -1 Then
Dim line1 As String
Dim line2 As String
Dim i As Integer = 6
While i = 6
Dim temp1 As String = text.Substring(0, 1)
Dim temp2 As String = text.Substring(1, 1)
line1 = line1 + temp1
line2 = line2 + temp2
text = text.Substring(2)
If text.Length = 0 Then
i = 2
End If
End While
Return line1 + line2
Else
MessageBox.Show("Number of Characters in message needs to be divisible by 4.", "Rail Fence 2 Line Encrypt")
End If
End Function
#End Region
#Region "Rail_Fence_2line_Decrypt"
Public Shared Function Rail_Fence_2line_Decrypt(ByVal text As String) As String
Dim b As Double = text.Length / 4
If b.ToString.IndexOf(".") = -1 Then
Dim line1 As String = text.Substring(0, (text.Length / 2))
text = text.Substring(text.Length / 2)
Dim line2 As String = text
Dim newstring As String
Dim i As Integer = 6
While i = 6
Dim temp1 As String = line1.Substring(0, 1)
Dim temp2 As String = line2.Substring(0, 1)
newstring = newstring + temp1 + temp2
line1 = line1.Substring(1)
line2 = line2.Substring(1)
If line1.Length = 0 And line1.Length = 0 Then
i = 2
End If
End While
Return newstring
Else
MessageBox.Show("Number of Characters in message needs to be divisible by 4.", "Rail Fence 2 Line Decrypt")
End If
End Function
#End Region
#Region "Polybius Fixed Checkboard Encrypt"
Public Shared Function Polybius_Fixed_Checkboard_encrypt(ByVal text As String) As String()
Dim i(text.Length) As Decimal
text = text.ToUpper
Dim cha As Char() = text.ToCharArray
Dim ch As Char
Dim where As Integer = 0
For Each ch In cha
If ch = "A" Then
i(where) = 1.1
ElseIf ch = "B" Then
i(where) = 1.2
ElseIf ch = "C" Then
i(where) = 1.3
ElseIf ch = "D" Then
i(where) = 1.4
ElseIf ch = "E" Then
i(where) = 1.5
ElseIf ch = "F" Then
i(where) = 2.1
ElseIf ch = "G" Then
i(where) = 2.2
ElseIf ch = "H" Then
i(where) = 2.3
ElseIf ch = "I" Then
i(where) = 2.4
ElseIf ch = "J" Then
i(where) = 2.5
ElseIf ch = "K" Then
i(where) = 3.1
ElseIf ch = "L" Then
i(where) = 3.2
ElseIf ch = "M" Then
i(where) = 3.3
ElseIf ch = "N" Then
i(where) = 3.4
ElseIf ch = "O" Then
i(where) = 3.5
ElseIf ch = "P" Then
i(where) = 4.1
ElseIf ch = "Q" Then
i(where) = 4.2
ElseIf ch = "R" Then
i(where) = 4.3
ElseIf ch = "S" Then
i(where) = 4.4
ElseIf ch = "T" Then
i(where) = 4.5
ElseIf ch = "U" Then
i(where) = 5.1
ElseIf ch = "V" Then
i(where) = 5.2
ElseIf ch = "W" Then
i(where) = 5.3
ElseIf ch = "X" Then
i(where) = 5.4
ElseIf ch = "Y" Then
i(where) = 5.5
ElseIf ch = "Z" Then
i(where) = 5.6
ElseIf ch = " " Then
i(where) = 5.7
End If
where = where + 1
Next
where = 0
Dim s As String
Dim sreturn(i.Length - 2) As String
For Each s In sreturn
sreturn(where) = i.GetValue(where)
where = where + 1
Next
Return sreturn
End Function
#End Region
#Region "Polybius Fixed Checkboard Decrypt"
Public Shared Function Polybius_Fixed_Checkboard_Decrypt(ByVal text As String()) As String
Dim s As String
Dim sreturn As String
Dim ch As String
For Each s In text
ch = s
If ch = "1.1" Then
If sreturn = "" Then
sreturn = "A"
Else
sreturn = sreturn + "A"
End If
ElseIf ch = "1.2" Then
If sreturn = "" Then
sreturn = "B"
Else
sreturn = sreturn + "B"
End If
ElseIf ch = "1.3" Then
If sreturn = "" Then
sreturn = "C"
Else
sreturn = sreturn + "C"
End If
ElseIf ch = "1.4" Then
If sreturn = "" Then
sreturn = "D"
Else
sreturn = sreturn + "D"
End If
ElseIf ch = "1.5" Then
If sreturn = "" Then
sreturn = "E"
Else
sreturn = sreturn + "E"
End If
ElseIf ch = "2.1" Then
If sreturn = "" Then
sreturn = "F"
Else
sreturn = sreturn + "F"
End If
ElseIf ch = "2.2" Then
If sreturn = "" Then
sreturn = "G"
Else
sreturn = sreturn + "G"
End If
ElseIf ch = "2.3" Then
If sreturn = "" Then
sreturn = "H"
Else
sreturn = sreturn + "H"
End If
ElseIf ch = "2.4" Then
If sreturn = "" Then
sreturn = "I"
Else
sreturn = sreturn + "I"
End If
ElseIf ch = "2.5" Then
If sreturn = "" Then
sreturn = "J"
Else
sreturn = sreturn + "J"
End If
ElseIf ch = "3.1" Then
If sreturn = "" Then
sreturn = "K"
Else
sreturn = sreturn + "K"
End If
ElseIf ch = "3.2" Then
If sreturn = "" Then
sreturn = "L"
Else
sreturn = sreturn + "L"
End If
ElseIf ch = "3.3" Then
If sreturn = "" Then
sreturn = "M"
Else
sreturn = sreturn + "M"
End If
ElseIf ch = "3.4" Then
If sreturn = "" Then
sreturn = "N"
Else
sreturn = sreturn + "N"
End If
ElseIf ch = "3.5" Then
If sreturn = "" Then
sreturn = "O"
Else
sreturn = sreturn + "O"
End If
ElseIf ch = "4.1" Then
If sreturn = "" Then
sreturn = "P"
Else
sreturn = sreturn + "P"
End If
ElseIf ch = "4.2" Then
If sreturn = "" Then
sreturn = "Q"
Else
sreturn = sreturn + "Q"
End If
ElseIf ch = "4.3" Then
If sreturn = "" Then
sreturn = "R"
Else
sreturn = sreturn + "R"
End If
ElseIf ch = "4.4" Then
If sreturn = "" Then
sreturn = "S"
Else
sreturn = sreturn + "S"
End If
ElseIf ch = "4.5" Then
If sreturn = "" Then
sreturn = "T"
Else
sreturn = sreturn + "T"
End If
ElseIf ch = "5.1" Then
If sreturn = "" Then
sreturn = "U"
Else
sreturn = sreturn + "U"
End If
ElseIf ch = "5.2" Then
If sreturn = "" Then
sreturn = "V"
Else
sreturn = sreturn + "V"
End If
ElseIf ch = "5.3" Then
If sreturn = "" Then
sreturn = "W"
Else
sreturn = sreturn + "W"
End If
ElseIf ch = "5.4" Then
If sreturn = "" Then
sreturn = "X"
Else
sreturn = sreturn + "X"
End If
ElseIf ch = "5.5" Then
If sreturn = "" Then
sreturn = "Y"
Else
sreturn = sreturn + "Y"
End If
ElseIf ch = "5.6" Then
If sreturn = "" Then
sreturn = "Z"
Else
sreturn = sreturn + "Z"
End If
ElseIf ch = "5.7" Then
If sreturn = "" Then
sreturn = " "
Else
sreturn = sreturn + " "
End If
End If
Next
Return sreturn
End Function
#End Region
I use the two algorithms in combination with a few others to make an encryption that is extremely hard to break.
Anyone on the forums try decrypting this:
uÈ×÷(”ÝÏþ[®¬ÈúèèžÙËeøÆl££³ã×ÓôlÃìÇdíÊŸêôð¯kÏÑýevÆÕûdê×Ãûëüç?«Åþur¿½aï|¥ýñéðžßÅrºà¨ïqî?”òíõëTµÓýqµïÑþ
It uses the two algorithms, plus a one time pad that requires two passwords.
Password1=Dark Basic Professional
Password2=The Game Creators
Hint: It the OneTimePad is done more than once.......1024 times as a matter of fact.
Here is the order of the encryption
Rail Fence 2 Line
Polybius Checkerboard
OneTimePad...OneTimePad...
Notice: If you try to decrypt the message do it on the computer as it will take hours to do it other wise. I used my home made encryption software that did all the repetitive tasks of the one time pad so it took seconds to make the encryption.
Click sig for DB Network X