Advertisement
6_2008-2009 Encryption #214294

Simple Hex Encode / Decode

Two functions: One to turn an ASCII string into a HEX string, and one to turn a HEX string into an ASCII string.

AI

Podsumowanie AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Kod źródłowy
original-source
'Encodes a string as hex
Public Function sHexEncode(sData As String) As String
 Dim iChar As Integer
 Dim sOutString As String
 Dim sTmpChar As String
 For iChar = 1 To Len(sData)
  sTmpChar = Hex$(Asc(Mid(sData, iChar, 1)))
  If Len(sTmpChar) = 1 Then sTmpChar = "0" & sTmpChar
  sOutString = sOutString & sTmpChar
 Next iChar
 sHexEncode = sOutString
End Function
'Decodes a string from hex
Public Function sHexDecode(sData As String) As String
 Dim iChar As Integer
 Dim sOutString As String
 Dim sTmpChar As String
 For iChar = 1 To Len(sData) Step 2
  sTmpChar = Chr("&H" & Mid(sData, iChar, 2))
  sOutString = sOutString & sTmpChar
 Next iChar
 sHexDecode = sOutString
End Function
Oryginalne komentarze (3)
Odzyskane z Wayback Machine