VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A simple Substitution function. Works on HEX data. (This generates the SBox)

by Glenn Larsson (5 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Mon 15th November 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

A simple Substitution function. Works on HEX data. (This generates the SBox)

Rate A simple Substitution function. Works on HEX data. (This generates the SBox)




' A key dependent SBox, feed a key dependent value (You figure it out; dead easy) info
' this function and voila..
'
' 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 A(256) As Integer

' MOD 256 it to 0>=n<=255

SBoxSeed = SBoxSeed Mod 256

' Fill the array with stuff
' -------------------------
For Z = 0 To 255
    A(Z) = (154 + Z) Mod 256
Next Z

' Generate the Substitution Box using the "Stuff" in the array
' ------------------------------------------------------------
For P = 0 To SBoxSeed
    For x = (67 + P) To 3 Step -1
        For Z = 0 To 255 Step (4 + x)
            s = Z + x
            If s > 255 Then s = s Mod 256
            C = A(s)
            B = A(Z)
            A(s) = B
            A(Z) = C
        Next Z
    Next x
Next P

' Convert the Array to a Hex string (Duuh?)
' -----------------------------------------

H:
For Z = 0 To 255
    L = ""
    If Len(Trim(Hex(A(Z)))) < 2 Then L = "0"
    TOT = TOT & L & Hex(A(Z))
Next Z

GenerateSBox = TOT

End Function


Download this snippet    Add to My Saved Code

A simple Substitution function. Works on HEX data. (This generates the SBox) Comments

No comments have been posted about A simple Substitution function. Works on HEX data. (This generates the SBox). Why not be the first to post a comment about A simple Substitution function. Works on HEX data. (This generates the SBox).

Post your comment

Subject:
Message:
0/1000 characters