Sign in to follow this  
Followers 0
Alexxander

Binary write to file

3 posts in this topic

hi all

im using an app on Android called tasker

it have a binary read feature

 

 

Screenshot_2014_03_31_14_14_48.png

i can read any file to binary and save the output to a text file

here is an example

the sound file file and the binary read of it 

http://ge.tt/43Xr1OV1?c

 

my question is how can i remake the file from the binary to file using autoit ?

 

binary.txt


Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this:

Global $sB64 = StringReplace((FileRead(@ScriptDir & "\binary.txt")), @LF, "")
Global $hFile = FileOpen(@ScriptDir &  "\binary.ogg", 18)
FileWrite($hFile, _WinAPI_Base64Decode($sB64))
FileClose($hFile)

Func _WinAPI_Base64Decode($sB64String)
    Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
    Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
    $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($bBuffer, 1)
EndFunc   ;==>_WinAPI_Base64Decode

Br,

UEZ

Edited by UEZ
1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

It worked !

thank  you UEZ you are awesome !

Edited by Alexxander

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