ogrish Posted August 15, 2011 Posted August 15, 2011 (edited) Hi guys,I use to get base64 encoding of a string. The code is as follows:#Include "Base64.au3" Dim $Encode = _Base64Encode("ps") MsgBox(0, 'Base64 Encode Data', $Encode)When running it, I got the result: cHM=Then I use the following PowerShell code to get the the base64 encoding of the same string "ps":$commands = 'ps' $bytes = [System.Text.Encoding]::Unicode.GetBytes($commands) $encodedString = [Convert]::ToBase64String($bytes) $encodedStringWhat I got is: cABzAA==Infact the result from PowerShell is what I want. I want to know how to get the same result using AutoIt? I guess this is a character encoding issue, not sure.Thanks. Edited August 15, 2011 by ogrish
JFX Posted August 15, 2011 Posted August 15, 2011 :Unicode.GetBytes($commands) maybe you should you a Unicode string in your script too.
jvanegmond Posted August 15, 2011 Posted August 15, 2011 http://stackoverflow.com/questions/7064776/how-can-i-get-the-same-base64-encoding-result-from-autoit-as-what-from-powershell #Include "Base64.au3" Dim $Encode = _Base64WEncode("ps") ConsoleWrite($Encode & @CRLF) Func _Base64WEncode($string) Local $result = "" Local $arr = StringSplit($string, "") For $i = 1 To UBound($arr) - 1 $result &= $arr[$i] & Chr(0) Next $result = _Base64Encode($result) Return $result EndFunc github.com/jvanegmond
ogrish Posted August 15, 2011 Author Posted August 15, 2011 :Unicode.GetBytes($commands) maybe you should you a Unicode string in your script too.Thanks JFX. You solved my problem. I use Lazycats Asc2Unicode solved my problem.
Moderators SmOke_N Posted August 15, 2011 Moderators Posted August 15, 2011 Curious, does this work for you? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
ogrish Posted August 16, 2011 Author Posted August 16, 2011 Curious, does this work for you?yes i tried, it works. Thanks!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now