!include LogicLib.nsh

Section
  StrCpy $0 "QWERTY"
  Push $0
  Call StrToCOdes
  Pop $1
  
  DetailPrint "$0 = $1"
SectionEnd

Function StrToCodes
  Exch $0 ; save $0, get string
  Push $1
  Push $2
  
  StrCpy $2 ""				; initialize the output codes
  ${While} $0 != ""
	StrCpy $1 $0 1			; get a single char
	Push $1
	Call CharToASCII		; convert a char to ascii value
	Pop $1
	IntOp $1 255 - $1		; mangle the ascii slightly !??
	IntFmt $1 "%02x" $1		; convert ascii to hex
	StrCpy $2 "$2$1"		; append new code to previous codes
	StrCpy $0 $0 "" 1		; remove first character
  ${EndWhile}
  Exch $2				; return the result
  Exch 2
  Pop $0				; restore registers
  Pop $1
FunctionEnd

# CharToASCII is from the NSIS wiki library
# contributed by Maester, July 2005
Function CharToASCII
  Exch $0 ; given character
  Push $1 ; current character
  Push $2 ; current Ascii Code   
  
  StrCpy $2 1 ; right from start
Loop:
  IntFmt $1 %c $2 ; Get character from current ASCII code
  ${If} $1 S== $0 ; case sensitive string comparison
     StrCpy $0 $2
     Goto Done
  ${EndIf}
  IntOp $2 $2 + 1
  StrCmp $2 255 0 Loop ; ascii from 1 to 255
  StrCpy $0 0 ; ASCII code was'nt found -> return 0
Done:         
  Pop $2
  Pop $1
  Exch $0
FunctionEnd