- Home
·
- String Manipulation
·
- A simple Substitution function. Works on HEX data. (This _Applies_ it to the HEX data, You also nee
A simple Substitution function. Works on HEX data. (This _Applies_ it to the HEX data, You also nee
A simple Substitution function. Works on HEX data. (This _Applies_ it to the HEX data, You also need the GenerateSBox() function.)
Rate A simple Substitution function. Works on HEX data. (This _Applies_ it to the HEX data, You also nee
(3(3 Vote))
'
' Disclaimer: This is not supposed to be used for any other purpose than to learn what an SBox is.
' This is not an encryption system but a part of one, if you use it AS one = Good luck!
'
' ABSOLUTELY NO SUPPORT will be provided via Email!
' Free for educational use (C) 1999 Glenn Larsson ([email protected])
'
Dim TMP As String
TMP = UCase(Data): Data = TMP ' Yes we should all be using UCase..
TMP = UCase(SBox): SBox = TMP
TMP = "0"
' Data = Hex data in a string you wish to apply the SBox on
' SBox = Hex string, the SBox returned from GenerateSbox()
' Marker
' 1 Encrypt
' 2 Decrypt
' Fairly simple..
If Marker = 1 Then GoTo Encrypt:
If Marker = 2 Then GoTo Decrypt:
Exit Function
Encrypt: ' Start the SBox
For BC = 1 To Len(Data) Step 2
CB = HexToDec(Mid(Data, BC, 2))
ZZ = 1 + (CB * 2)
If ZZ < 0 Then ZZ = 0
RCB = Mid(SBox, ZZ, 2)
TOT = TOT & RCB
Next BC
GoTo Nding:
Decrypt: ' Reverse the SBox
For BC = 1 To Len(Data) Step 2
CB = Mid(Data, BC, 2)
For I = 1 To 512 Step 2
If Mid(SBox, I, 2) = CB Then RCB = ((I + 1) / 2)
Next I
RCB = RCB - 1
L = "" ' return proper 2 digit Hex value
If RCB < 16 Then L = "0"
TOT = TOT & L & Hex(RCB)
Next BC
GoTo Nding:
Nding:
ApplySBox = TOT
End Function
A simple Substitution function. Works on HEX data. (This _Applies_ it to the HEX data, You also nee Comments
No comments yet — be the first to post one!
Post a Comment