发新话题
打印

演示如何替换替换

演示如何替换替换

  Function ApplySBox(ByVal Data As String, ByVal SBox As String, ByVal Marker As Integer) As String
' 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 (ichinin@swipnet.se)'

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

TOP

发新话题