Sign in to follow this  
Followers 0
noorm

Base64 decoder/encoder, Internet header decoders, email subject decoder, UTF-8, ISO-8859-1, telnet negociations

1 post in this topic

Hello!

I've been lurking around for a loooong time... and I decided to finally share a little. I do a lot of internet stuff, mostly machine to machine for work (instrumentation) so I have quite a few "RFC" scripts.

Disclaimer these work for me... but I sometime use... "shortcuts" based on my particular requirement. An example, the Base64 encoding snippet might not be too good for binary data. I pad the original data with spaces to avoid the "==" padding of base64.

So... first is the base64 encoding snippet. It is not in a function, it was in a sequential program, used only once! It encode $Graph to $SMTPMessage:

; Create the base64 encoding table
Dim $Base64EncodingTable[0]
For $Cpt = Asc("A") to Asc("Z")
    _ArrayAdd($Base64EncodingTable, Chr($Cpt))
Next
For $Cpt = Asc("a") to Asc("z")
    _ArrayAdd($Base64EncodingTable, Chr($Cpt))
Next
For $Cpt = Asc("0") to Asc("9")
    _ArrayAdd($Base64EncodingTable, Chr($Cpt))
Next
_ArrayAdd($Base64EncodingTable, "+")
_ArrayAdd($Base64EncodingTable, "/")

; Pad the SVG Graph to attach with space(s). Lazy way to avoid base64 == pading
While Mod(StringLen($Graph), 3) <> 0
    $Graph &= " "
WEnd

; Start from the first character
$Cpt = 1

Do
    ; Extract the 3 characters to encode
    $Char1 = Asc(StringMid($Graph, $Cpt, 1))
    $Char2 = Asc(StringMid($Graph, $Cpt+1, 1))
    $Char3 = Asc(StringMid($Graph, $Cpt+2, 1))

    ; Encode them to 4 characters
    $SMTPMessage &= $Base64EncodingTable[BitShift(BitAND($Char1, 252), 2)]
    $SMTPMessage &= $Base64EncodingTable[BitShift(BitAND($Char1, 3), -4) + BitShift(BitAND($Char2, 240), 4)]
    $SMTPMessage &= $Base64EncodingTable[BitShift(BitAND($Char2, 15), -2) + BitShift(BitAND($Char3, 192), 6)]
    $SMTPMessage &= $Base64EncodingTable[BitAND($Char3, 63)]

    ; Increment the counter, and if required, add a @CRLF to split in multiples lines
    $Cpt += 3
    If Mod($Cpt, 57) = 1 Then $SMTPMessage &= @CRLF

; Do this until all the graph has been encoded
Until $Cpt >= StringLen($Graph)

 

Second... I just finished this one and was allready thinking about sharing it... so it's been encapsulated into function a bit more. I use it to decode email subjects in a system where you can update something by email. I separated the Base64Decode function so it can be grabbed more easily. Please note that it return an hex string so you would still need to convert it if it's a string with BinaryToString or whatever suit your needs.

If can be copied as is and runned directly... it include my test strings! (Yes... I'm french!)

; For the $SB_UTF8 and $SB_ANSI Variable
#include <StringConstants.au3>

; For _ArrayAdd and _ArraySearch used in the Base64 decoder
#include <Array.au3>

; Various test sentences...
;$text = "=?UTF-8?Q?Ce=c3=a7i_est_un_autre_test!_h=c3=a9h=c3=a9!?="         ; Normal UTF-8
;$text = "=?UTF-8?Q?Encore_=3d_un_autre_test_=c3=a9_?="                     ; "=" added
;$text = "=?UTF-8?Q?un_autre_test_=5f_=c3=a9?="                             ; "_" added
;$text = "=?UTF-8?B?Q2XDp2kgZXN0IHVuIGF1dHJlIHRlc3QhID0gXyBow6low6kh?="     ; UTF-8 Base64
$text = "=?UTF-8?B?ZcOnaSBlc3QgdW4gYXV0cmUgdGVzdCEgPSBfIGjDqWjDqSE=?="      ; UTF-8 Base64 with padding
;$text = "=?iso-8859-1?Q?Ce=E7i_est_un_test!?="                             ; iso-8859-1
MsgBox(0, "", DecodeHeader($text))

Func DecodeHeader($lString)

    ; Check and store encoding type
    If StringInStr($lString, "?Q?") Then
        ; Quoted printable content
        $lType = "?Q?"
    ElseIf StringInStr($lString, "?B?") Then
        ; Base64 encoding
        $lType = "?B?"
    Else
        ; No encoding (or unknown encoding)
        return($lString)
    EndIf

    ; Start of the charset string
    $lStart = StringInStr($lString, "=?") + 2

    ; End of the charset string
    $lStop = StringInStr($lString, $lType)

    ; Charset variable, storing "UTF-8" or "iso-8859-1"
    $lEncoding = StringMid($lString, $lStart, $lStop-$lStart)

    ; Change encoding type for the BinaryToString flag
    If $lEncoding = "UTF-8" Then
        $lEncoding = $SB_UTF8
    ElseIf $lEncoding = "iso-8859-1" Then
        $lEncoding = $SB_ANSI
    Else
        MsgBox(0, "", "Unknown character set")
        Exit
    EndIf

    ; Start of the actual encoded content
    $lStart = $lStop + 3

    ; End of the actual encoded content
    $lStop = StringInStr($lString, "?=")

    ; Actual content to decode
    $lString = StringMid($lString, $lStart, $lStop-$lStart)

    ; For Quoted printable content
    If $lType == "?Q?" Then

        ; Restore underscore encoded spaces
        $lString = StringReplace($lString, "_", " ")

        ; Starting with the first character of the string
        $lCpt = 1

        ; "=XX" search and convert loop
        While 1

            ; There will be 0 characters to convert in that block unless...
            $lConvertableLenght = 0

            ; That character, and another one 3 bytes over... and the next, and the next...
            For $lCpt2 = 0 to 100

                ; Is equal to "="
                If StringMid($lString, $lCpt+($lCpt2*3), 1) == "=" Then

                    ; In that case, yes, we will have to convert 3 more characters
                    $lConvertableLenght += 3
                Else

                    ; But if we fail to find or reach the end of a block of encoded characters, exit the search
                    ExitLoop
                EndIf
            Next

            ; If we did in fact find some encoded characters
            If $lConvertableLenght > 0 Then

                ; Extract that block of encoded characters
                $lConvertableString = StringMid($lString, $lCpt, $lConvertableLenght)

                ; Convert it
                $lConvertedString = BinaryToString("0x" & StringReplace($lConvertableString, "=", ""), $lEncoding)

                ; Replace it in the original
                $lString = StringReplace($lString, $lConvertableString, $lConvertedString)
            EndIf

            ; Increment the "=XX" search and convert loop counter
            $lCpt += 1

            ; If we reached the end of the string, exit the "=XX" search and convert loop
            If $lCpt >= StringLen($lString) Then ExitLoop

        ; Continue searching in the "=XX" search and convert loop
        WEnd

    ; For Base64 encoded strings
    Else

        ; Use the separate Base64Decode function
        $lString = Base64Decode($lString)
        $lString = BinaryToString($lString, $lEncoding)
    EndIf

    return($lString)
EndFunc

Func Base64Decode($lEncoded)

    ; Create the base64 encoding table
    Dim $Base64EncodingTable[0]
    For $Cpt = Asc("A") to Asc("Z")
        _ArrayAdd($Base64EncodingTable, Chr($Cpt))
    Next
    For $Cpt = Asc("a") to Asc("z")
        _ArrayAdd($Base64EncodingTable, Chr($Cpt))
    Next
    For $Cpt = Asc("0") to Asc("9")
        _ArrayAdd($Base64EncodingTable, Chr($Cpt))
    Next
    _ArrayAdd($Base64EncodingTable, "+")
    _ArrayAdd($Base64EncodingTable, "/")

    ; Start from the first character
    $Cpt = 1
    $Decoded = "0x"

    Do
        ; Extract the 4 characters to encode
        $Char1 = StringMid($lEncoded, $Cpt, 1)
        $Char2 = StringMid($lEncoded, $Cpt+1, 1)
        $Char3 = StringMid($lEncoded, $Cpt+2, 1)
        $Char4 = StringMid($lEncoded, $Cpt+3, 1)

        ; Decode them
        $Decoded &= Hex(BitShift(_ArraySearch($Base64EncodingTable, $Char1, 0, 0, 1), -2) + BitShift(BitAnd(_ArraySearch($Base64EncodingTable, $Char2, 0, 0, 1), 48), 4), 2)
        If $Char3 <> "=" Then $Decoded &= Hex(BitShift(BitAnd(_ArraySearch($Base64EncodingTable, $Char2, 0, 0, 1), 15), -4) + BitShift(BitAnd(_ArraySearch($Base64EncodingTable, $Char3, 0, 0, 1), 60), 2), 2)
        If $Char4 <> "=" Then $Decoded &= Hex(BitShift(BitAnd(_ArraySearch($Base64EncodingTable, $Char3, 0, 0, 1), 3), -6) + _ArraySearch($Base64EncodingTable, $Char4, 0, 0, 1), 2)

        ; Increment the counter
        $Cpt += 4

    ; Do this until all the encoded string has been decoded
    Until $Cpt >= StringLen($lEncoded)

    return($Decoded)
EndFunc

 

Last thing... I may update it into a better format for you, like a standalone telnet program with GUI. It is my telnet options negociations loops. The basic concept is systematically deny all request for special options and keep it "raw".

If server says "Will", I reply "Don't". If it says "Do", I reply "Wont"... unless it's the terminal type subnegociation, in which case I reply xterm!

$Data for now needs to be Global. You still need to know what you're doing, opening sockets and making a basic communication loop or something.

Global $T_Is = Chr(0)
Global $T_Send = Chr(1)
Global $T_TerminalType = Chr(24)
Global $T_SE = Chr(240)
Global $T_SB = Chr(250)
Global $T_Will = Chr(251)
Global $T_Wont = Chr(252)
Global $T_Do = Chr(253)
Global $T_Dont = Chr(254)
Global $T_IAC = Chr(255)

Func NegotiateTelnetOptions()
    $NegotiationCommandsToSendBack = ""
    While StringInStr($Data, $T_IAC)
        $IACPosition = StringInStr($Data, $T_IAC)
        Switch StringMid($Data, $IACPosition+1, 1)
            Case $T_Will
                $NegotiationCommandsToSendBack &= CraftReply_CleanUpData($IACPosition, $T_Dont)
            Case $T_Do
                If StringMid($Data, $IACPosition+2, 1) = $T_TerminalType Then
                    $NegotiationCommandsToSendBack &= CraftReply_CleanUpData($IACPosition, $T_Will)
                Else
                    $NegotiationCommandsToSendBack &= CraftReply_CleanUpData($IACPosition, $T_Wont)
                EndIf
            Case $T_SB
                If StringMid($Data, $IACPosition, 6) = ($T_IAC & $T_SB & $T_TerminalType & $T_Send & $T_IAC & $T_SE) Then
                    $NegotiationCommandsToSendBack &= $T_IAC & $T_SB & $T_TerminalType & $T_Is & "xterm" & $T_IAC & $T_SE
                    $Data = StringReplace($Data, StringMid($Data, $IACPosition, 6), "")
                Else
                    MsgBox(0, "", "Unknown Subnegotiation...") ; Should never happen.
                    Exit
                EndIf
        EndSwitch
    WEnd
    Return $NegotiationCommandsToSendBack
EndFunc

Func CraftReply_CleanUpData($IACPosition, $Reply)
    $PartialCommandToSendBack = $T_IAC & $Reply & StringMid($Data, $IACPosition+2, 1)
    $Data = StringReplace($Data, StringMid($Data, $IACPosition, 3), "")
    Return $PartialCommandToSendBack
EndFunc

 

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • rootx
      By rootx
      I need help with unicode char ü I get some text from online json but if try to read 4 example Zürich I heave  Zürich.
      How can I convert with autoit unicode to a clear character readable? thx
    • wakillon
      By wakillon
      BinaryToAu3Kompressor v1.0.5.4
       

       
      It's now possible to see the best compression ratio using LZMA, LZNT and Base64 compressions with differents combinations.
      Nothing too complicate, you drag'n drop a file on the picture and script Test all compression types and return the ratios.
      ( Test duration depends of file size, slowest compression is LZNT, but all decompressions are fast  )
      Free to you after, to choose the compression(s) you want...
      Yes, LZMA needs a dll ( embedded & compressed in script ) but brings a powerfull compression. 
      It opens scite with your file compressed to an au3 script with or without decompression function as you want.
      Hold Left Shift key when clicking button for just copy script to clipboard.
      Use the 3 compressions at a time works but doesn't give a good ratio, that's why i don't display it.
      Usefull for little files you want include in your scripts !
      No externals files needed, they are already in script.
      Previous downloads : 1103
      Source and Executable
      BinaryToAu3Kompressor will be added to the next version of >SciTEHopper
      Thanks to Ward for his >Base64.au3 and LZMA.au3, and trancexx for his >LZNT functions and his >Base64Decode function.
    • 4bst1n3nz
      By 4bst1n3nz
      Hello,
      i need to save files with ANSI-Encoding. Since 3.3.14.2 Auto-It it doesn't work in any direction.
      I tried the following:
      #include <FileConstants.au3> FileDelete(@ScriptDir&"\Test.txt") $o = FileOpen(@ScriptDir&"\Test.txt", BitOR($FO_BINARY,$FO_ANSI,$FO_OVERWRITE)) FileWrite($o, "Test") FileClose($o) Or
      #include <FileConstants.au3> FileDelete(@ScriptDir&"\Test.txt") $o = FileOpen(@ScriptDir&"\Test.txt", 514) FileWrite($o, "Test") FileClose($o) Both create UTF-8 encoded files.
      What am i doing wrong?
      Thank you!
    • Beege
      By Beege
      This is a small UDF I put together just for fun that will embed and extract complete directory's in and from your script. It only has two functions, _EmbeddedDirectory_Create() and _EmbeddedDirectory_Extract(). The udf uses Wards machine code functions so they have pretty good speed. The example I set up packs all files located in Autoit Include directory. Both compression and decompression of the directory was less than 500ms on my pc which I was happy with. Let me if you have any problems or questions. Thanks
       
      Example:
       
      #include "EmbedDir.au3" ;Check location of autoit includes Global $sIncludeDir = 'C:\Program Files\AutoIt3\Include\' If Not FileExists($sIncludeDir) Then $sIncludeDir = 'C:\Program Files (x86)\AutoIt3\Include\' If Not FileExists($sIncludeDir) Then Exit (MsgBox(0, 'Directory Not Found', 'Unable to locate Includes Directory')) ;Create embedded directory function Global $sCompressed_Includes = _EmbeddedDirectory_Create($sIncludeDir, '_Extract_Includes') Global $iTime = (@extended / 1000) & ' ms' ;create example file and write extract function to it Global $hExtractExample = FileOpen(@ScriptDir & 'Extract_Example.au3', 2) FileWrite($hExtractExample, '#include "EmbedDir.au3"' & @LF & @LF & _ '$sExt = _Extract_Includes()' & @LF & _ '_EmbeddedDirectory_Extract($sExt, @ScriptDir & "AutoIt_Extracted")' & @LF & _ 'ConsoleWrite("Extract Time = " & @extended/1000 & "ms" & @LF)' & @LF & @LF & _ $sCompressed_Includes) FileClose($hExtractExample) ;Show stats of the directory we just embeded $aSize = DirGetSize($sIncludeDir,1) If IsArray($aSize) Then Msgbox(0,"Directory Details", _ "Size = " & Int($aSize[0]/1024) & 'KB' & @LF & _ "Files = " & $aSize[1] & @LF & _ "Dirs = " & $aSize[2] & @LF & _ "Compression time = " & $iTime & @LF & @LF & _ "Open Extract_Example.au3 to extract") EndIf  
      UDF:
      EmbedDir.zip
    • wakillon
      By wakillon
      Do not expect a SVG file as Sodipodi, Inkscape or Adobe Illustrator can generate.
      This "converter" doesn't actually trace or convert the image to vector. 
      It just embed the bitmap image within an SVG container.
      #Region ;************ Includes ************ #Include <GDIPlus.au3> #Include <Memory.au3> #EndRegion ;************ Includes ************ Global $_B64E_CodeBuffer, $_B64E_CodeBufferMemory, $_B64E_Init, $_B64E_EncodeData, $_B64E_EncodeEnd Global $sFile, $hImage, $iW, $iH, $sType, $hFile, $sBase64String, $sFileRead, $sSvgPath, $sString _GDIPlus_Startup() $sFile = FileOpenDialog ( 'Select an Image', @DesktopDir, 'Images (*.jpg;*.png;*.gif;*.bmp)', 1+2 ) If @error Then Exit $sType = _FileGetType ( $sFile ) If @error Then ConsoleWrite ( '! File Type not supported, error : ' & @error & @Crlf ) Else $hFile = FileOpen ( $sFile, 16 ) If $hFile=-1 Then Exit MsgBox ( 262144+4096+16, 'Error', 'Can not Access this file.', 4 ) $hImage = _GDIPlus_ImageLoadFromFile ( $sFile ) $iW = _GDIPlus_ImageGetWidth ( $hImage ) $iH = _GDIPlus_ImageGetHeight ( $hImage ) _GDIPlus_ImageDispose ( $hImage ) $sFileRead = FileRead ( $hFile ) FileClose ( $hFile ) $sBase64String = _Base64Encode ( $sFileRead, 4000 ) $sString = '<svg' & @CRLF & _ ' version="1.1"' & @CRLF & _ ' xmlns="http://www.w3.org/2000/svg"' & @CRLF & _ ' xmlns:xlink="http://www.w3.org/1999/xlink"' & @CRLF & _ ' width="' & $iW & 'px" height="' & $iH & 'px"' & @CRLF & _ ' viewBox="0 0 ' & $iW & ' ' & $iH & '" preserveAspectRatio="none">' & @CRLF & _ ' <g>' & @CRLF & _ '<image width="' & $iW & '" height="' & $iH & '" xlink:href="data:image/' & $sType & ';base64,' & @CRLF & _ $sBase64String & @CRLF & _ '"/>' & @CRLF & _ ' </g>' & @CRLF & _ '</svg>' & @CRLF $sSvgPath = @TempDir & '\' & @HOUR & @MIN & @SEC & @MSEC & '-' & $iW & 'x' & $iH & '.svg' $hFile = FileOpen ( $sSvgPath, 1+2+8 ) If $hFile = -1 Then MsgBox ( 262144+4096+16, '', 'An error occurred whilst writing the temporary file.' ) Else FileWrite ( $hFile, $sString ) FileClose ( $hFile ) ShellExecute ( 'iexplore.exe', $sSvgPath ) EndIf EndIf _GDIPlus_Shutdown() Exit Func _FileGetType ( $sFilePath ) If Not FileExists ( $sFilePath ) Then Return SetError ( -1 ) If FileGetSize ( $sFilePath ) = 0 Then Return SetError ( 1, 0, 0 ) Local $hFile, $Binary, $Ret $hFile = FileOpen ( $sFilePath, 16 ) If $hFile = -1 Then Return SetError ( 3, 0, 0 ) $Binary = FileRead ( $hFile ) FileClose ( $hFile ) Local $sString = StringTrimLeft ( $Binary, 2 ) Local $sStringLeft = StringReplace ( StringTrimLeft ( StringLeft ( $Binary, 14 ), 2 ), '00', '' ) Local $sStringLeft12 = StringLeft ( $sStringLeft, 12 ) Local $sStringLeft8 = StringLeft ( $sStringLeft, 8 ) Local $sStringLeft4 = StringLeft ( $sStringLeft, 4 ) Select Case $sStringLeft12 = '474946383961' Or $sStringLeft12 = '474946383761' $Ret = 'GIF' Case $sStringLeft4 = 'FFD8' $Ret = 'JPG' Case $sStringLeft4 = '424D' $Ret = 'BMP' Case $sStringLeft8 = '89504E47' $Ret = 'PNG' Case Else Return SetError ( 2, 0, '' ) EndSelect If $Ret = 'GIF' Then StringReplace ( $sString, '0021F904', '0021F904' ) If @extended > 1 Then Return SetError ( 3, 0, '' ) ; animated gif. EndIf Return $Ret EndFunc ;==> _FileGetType() Func _Base64E_Exit() ; by Ward $_B64E_CodeBuffer = 0 _MemVirtualFree ( $_B64E_CodeBufferMemory, 0, $MEM_RELEASE ) EndFunc ;==> _Base64E_Exit() Func _Base64Encode ( $Data, $LineBreak=76 ) ; by Ward Local $State = _Base64EncodeInit ( $LineBreak ) Return _Base64EncodeData ( $State, $Data ) & _Base64EncodeEnd ( $State ) EndFunc ;==> _Base64Encode() Func _Base64EncodeData ( ByRef $State, $Data ) ; by Ward If Not IsDllStruct ( $_B64E_CodeBuffer ) Or Not IsDllStruct ( $State ) Then Return SetError ( 1, 0, '' ) $Data = Binary ( $Data ) Local $InputLen = BinaryLen ( $Data ) Local $Input = DllStructCreate ( 'byte[' & $InputLen & ']' ) DllStructSetData ( $Input, 1, $Data ) Local $OputputLen = Ceiling ( BinaryLen ( $Data )*1.4 )+3 Local $Output = DllStructCreate ( 'char[' & $OputputLen & ']' ) DllCall ( 'user32.dll', 'int', 'CallWindowProc', 'ptr', DllStructGetPtr ( $_B64E_CodeBuffer )+$_B64E_EncodeData, 'ptr', DllStructGetPtr ( $Input ), 'uint', $InputLen, 'ptr', DllStructGetPtr ( $Output ), 'ptr', DllStructGetPtr ( $State ) ) Return DllStructGetData ( $Output, 1 ) EndFunc ;==> _Base64EncodeData() Func _Base64EncodeEnd ( ByRef $State ) ; by Ward If Not IsDllStruct ( $_B64E_CodeBuffer ) Or Not IsDllStruct ( $State ) Then Return SetError ( 1, 0, '' ) Local $Output = DllStructCreate ( 'char[5]' ) DllCall ( 'user32.dll', 'int', 'CallWindowProc', 'ptr', DllStructGetPtr ( $_B64E_CodeBuffer ) + $_B64E_EncodeEnd, 'ptr', DllStructGetPtr ( $Output ), 'ptr', DllStructGetPtr ( $State ), 'int', 0, 'int', 0 ) Return DllStructGetData ( $Output, 1 ) EndFunc ;==> _Base64EncodeEnd() Func _Base64EncodeInit ( $LineBreak=76 ) ; by Ward If Not IsDllStruct ( $_B64E_CodeBuffer ) Then If @AutoItX64 Then Local $Opcode = '0x89C08D42034883EC0885D2C70100000000C64104000F49C2C7410800000000C1F80283E20389410C740683C00189410C4883C408C389C94883EC3848895C242848897424304889CB8B0A83F901742083F9024889D87444C6000A4883C001488B74243029D8488B5C24284883C438C30FB67204E803020000BA3D0000004080FE3F7F08480FBEF60FB614308813C643013D488D4303C643023DEBBC0FB67204E8D7010000BA3D0000004080FE3F7F08480FBEF60FB614308813C643013D488D4302EB9489DB4883EC68418B014863D248895C242848897424304C89C348897C24384C896424484C89CE83F80148896C24404C896C24504C897424584C897C24604C8D2411410FB6790474434D89C64989CD0F82F700000083F8024C89C5747B31C0488B5C2428488B742430488B7C2438488B6C24404C8B6424484C8B6C24504C8B7424584C8B7C24604883C468C34C89C54989CF4D39E70F840B010000450FBE374D8D6F014489F025F0000000C1F80409C7E8040100004080FF3FBA3D0000007F08480FBEFF0FB614384489F78855004883C50183E70FC1E7024D39E50F84B2000000450FB675004983C5014489F025C0000000C1F80609C7E8BD0000004080FF3FBA3D0000007F08480FBEFF0FB61438BF3F0000008855004421F74C8D7502E896000000480FBED70FB604108845018B460883C0013B460C89460875104C8D7503C645020AC7460800000000904D39E5742E410FBE7D004D8D7D01498D6E01E8560000004889FA83E70348C1EA02C1E70483E23F0FB60410418806E913FFFFFF4489F040887E04C7060000000029D8E9CCFEFFFF89E840887E04C7060200000029D8E9B9FEFFFF89E840887E04C7060100000029D8E9A6FEFFFFE8400000004142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392B2F58C3' Else Local $Opcode = '0x89C08B4C24088B44240489CAC1FA1FC1EA1E01CAC1FA0283E103C70000000000C6400400C740080000000089500C740683C20189500CC2100089C983EC0C8B4C2414895C24048B5C2410897424088B1183FA01741D83FA0289D87443C6000A83C0018B74240829D88B5C240483C40CC210000FB67104E80C020000BA3D00000089F180F93F7F0989F20FBEF20FB6143088138D4303C643013DC643023DEBBD0FB67104E8DF010000BA3D00000089F180F93F7F0989F20FBEF20FB6143088138D4302C643013DEB9489DB83EC3C895C242C8B5C244C896C24388B542440897424308B6C2444897C24348B030FB6730401D583F801742D8B4C24488954241C0F820101000083F80289CF747D31C08B5C242C8B7424308B7C24348B6C243883C43CC210008B4C244889D739EF0F84400100008D57010FBE3F89542418894C241489F825F0000000C1F80409C6897C241CE8330100008B542418C644240C3D8B4C241489C789F03C3F7F0B0FBEF00FB604378844240C0FB644240C8D790188018B74241C83E60FC1E60239EA0F84CB0000000FB60A83C2018954241C89C825C0000000C1F80609C6884C2414E8D8000000BA3D0000000FB64C24148944240C89F03C3F7F0B0FBEF08B44240C0FB6143083E13F881789CEE8AD00000089F10FBED18D4F020FB604108847018B430883C0013B430C894308750EC647020A8D4F03C7430800000000396C241C743A8B44241C8B7C241C0FBE30894C241483C701E8650000008B4C241489F283E60381E2FC000000C1EA02C1E6040FB60410880183C101E9E4FEFFFF89F088430489C8C703000000002B442448E9B2FEFFFF89F189F8884B04C703020000002B442448E99CFEFFFF89F088430489C8C703010000002B442448E986FEFFFFE8400000004142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392B2F58C3' EndIf $_B64E_Init = ( StringInStr ( $Opcode, '89C0' )-3 ) / 2 $_B64E_EncodeData = ( StringInStr ( $Opcode, '89DB' )-3 ) / 2 $_B64E_EncodeEnd = ( StringInStr ( $Opcode, '89C9' )-3 ) / 2 $Opcode = Binary ( $Opcode ) $_B64E_CodeBufferMemory = _MemVirtualAlloc ( 0, BinaryLen ( $Opcode ), $MEM_COMMIT, $PAGE_EXECUTE_READWRITE ) $_B64E_CodeBuffer = DllStructCreate ( 'byte[' & BinaryLen ( $Opcode ) & ']', $_B64E_CodeBufferMemory ) DllStructSetData ( $_B64E_CodeBuffer, 1, $Opcode ) OnAutoItExitRegister ( '_Base64E_Exit' ) EndIf Local $State = DllStructCreate ( 'byte[16]' ) DllCall ( 'user32.dll', 'none', 'CallWindowProc', 'ptr', DllStructGetPtr ( $_B64E_CodeBuffer )+$_B64E_Init, 'ptr', DllStructGetPtr ( $State ), 'uint', $LineBreak, 'int', 0, 'int', 0 ) Return $State EndFunc ;==> _Base64EncodeInit() Thanks to Ward for his Base64 functions.