Hexadecimal Encoding
Hexadecimal
Verse from sprintermax/UEFNVerseSnippets (VerseLogic/ExtraModules/Encoding/Hexadecimal.verse), by sprintermax, under the MIT license. Pinned at commit a6b6363bd. Compile-checked and ready to adapt for UEFN.
-
Hexadecimal<public> := module{ using. BitMath using. MathFeatures using. StringProcessing UpperCaseHexAlphabet<public> : string = "0123456789ABCDEF" LowerCaseHexAlphabet<public> : string = "0123456789abcdef" ReverseHexTable<public> : [char]int = map{ '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9, 'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13, 'E' => 14, 'F' => 15, 'a' => 10, 'b' => 11, 'c' => 12, 'd' => 13, 'e' => 14, 'f' => 15 } # Converts a single byte (0-255) to its two-character hexadecimal representation # By default uses uppercase letters, but can use lowercase if wanted (for ex in MD5 Hashes) # Fails if the input is outside the byte range EncodeByteToHex<public>(Byte:int, ?LowerCase:logic=false)<computes><decides>:string = { HexAlphabet := LowerCase? and LowerCaseHexAlphabet or UpperCaseHexAlphabet
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.