Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/21/2014 in all areas

  1. I guess there is no need to explain what Base64 encoding is and what is used for. What is special about this way. Well, I did some testing and it turns that it's fast. About three times faster than the fastest way posted here on this forum (machine code implementation). It's calling functions "CryptBinaryToString" and "CryptStringToBinary" in Crypt32.dll I'm in the phase when discovering functions DllCall(), DllStructCreate(),... and related, so please be gentle to me, lol There is no error checking mainly because of the sentence before this one. If someone is willing to add that to the code below (or correct possible mistakes), I'm willing to learn out of that. So, please do. Here's the script: Updated 29th October 2008 - error checking added and some code optimization $encoded = _Base64Encode("Testing") MsgBox(0, 'Base64 Encoded', $encoded) $decoded = _Base64Decode($encoded) MsgBox(0, 'Base64 Decoded - binary', $decoded) MsgBox(0, 'Base64 Decoded - string', BinaryToString($decoded)) Func _Base64Encode($input) $input = Binary($input) Local $struct = DllStructCreate("byte[" & BinaryLen($input) & "]") DllStructSetData($struct, 1, $input) Local $strc = DllStructCreate("int") Local $a_Call = DllCall("Crypt32.dll", "int", "CryptBinaryToString", _ "ptr", DllStructGetPtr($struct), _ "int", DllStructGetSize($struct), _ "int", 1, _ "ptr", 0, _ "ptr", DllStructGetPtr($strc)) If @error Or Not $a_Call[0] Then Return SetError(1, 0, "") ; error calculating the length of the buffer needed EndIf Local $a = DllStructCreate("char[" & DllStructGetData($strc, 1) & "]") $a_Call = DllCall("Crypt32.dll", "int", "CryptBinaryToString", _ "ptr", DllStructGetPtr($struct), _ "int", DllStructGetSize($struct), _ "int", 1, _ "ptr", DllStructGetPtr($a), _ "ptr", DllStructGetPtr($strc)) If @error Or Not $a_Call[0] Then Return SetError(2, 0, ""); error encoding EndIf Return DllStructGetData($a, 1) EndFunc ;==>_Base64Encode Func _Base64Decode($input_string) Local $struct = DllStructCreate("int") $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _ "str", $input_string, _ "int", 0, _ "int", 1, _ "ptr", 0, _ "ptr", DllStructGetPtr($struct, 1), _ "ptr", 0, _ "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(1, 0, "") ; error calculating the length of the buffer needed EndIf Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]") $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _ "str", $input_string, _ "int", 0, _ "int", 1, _ "ptr", DllStructGetPtr($a), _ "ptr", DllStructGetPtr($struct, 1), _ "ptr", 0, _ "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(2, 0, ""); error decoding EndIf Return DllStructGetData($a, 1) EndFunc ;==>_Base64Decode There is @CRLF every 64 chars in return of _Base64Encode(). _Base64Decode() will return binary data. That is intentional to avoid Chr(0) issue. Convert it to string using BinaryToString() Microsoft about requirements: Client - Requires Windows Vista or Windows XP. Server - Requires Windows Server 2008 or Windows Server 2003.
    1 point
  2. Now that I have been learning to do a few things with GDI+, I decided it was time to port my old barcode generators to Autoit. It will generate a code length optimized Code128A/B/C barcode. Code128Auto.zip The ZIP file contains the UDF source and a very simple demo. ========== I am consolidating all of my barcode UDFs into one topic. Please refer to the new location for updates. http://www.autoitscript.com/forum/topic/170087-barcode-generators/ ==========
    1 point
  3. I think the parameter to vertically center the text is not present in the udf Could be resolved vertically centering the entire _GUICtrlRichLabel that might be good to center sentences no longer than one line here an attempt that could do: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "include\GUIRichLabel.au3" $SlideGUI = GUICreate("Form1", 615, 437, 192, 124) $aGuiSizes = WinGetClientSize($SlideGUI) $nFontSize = 30 $nVpos = $aGuiSizes[1] / 2 - $nFontSize $sLabel1_Data = '<font color="ffd200" size="' & $nFontSize & '" attrib="italic+bold" align="c">TEST</font>' $nLabel1 = _GUICtrlRichLabel_Create($SlideGUI, $sLabel1_Data, 0, $nVpos, 615, $nFontSize * 2) GUISetState(@SW_SHOW) MsgBox(0, "Pause", "Click here to end")
    1 point
  4. As an alternative, you can always do something like this: #include "WinHttp.au3" MsgBox(4096, "", GoogleTranslate("hometown", "el")) Func GoogleTranslate($sString, $sTo, $sFrom = "auto") Local $hOpen = _WinHttpOpen("Mozilla/5.0") Local $hConnect = _WinHttpConnect($hOpen, "https://translate.google.com") Local $sRead = _WinHttpSimpleSSLRequest($hConnect, Default, "translate_a/t?client=t&sl=" & $sFrom & "&text=" & __WinHttpURLEncode($sString) & "&tl=" & $sTo) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Return $sRead EndFunc
    1 point
  5. Glad you found a solution to your needs.
    1 point
  6. since almost always encoding is UTF8, you should decode it like this: $sHTMLsource = BinaryToString($sHTMLsource,4) ;to decode as UTF8
    1 point
  7. water

    HighlightColorIndex

    Welcome to AutoIt and the forum! HighlightColorIndex is a property of the range object. So there is no Color property of the HighlightColorIndex property. What do you try to achieve?
    1 point
×
×
  • Create New...