Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Base64 Converter


  • Please log in to reply
82 replies to this topic

#61 JoshDB

JoshDB

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 251 posts

Posted 17 May 2006 - 12:53 AM

Very helpful UDF, thanks a lot :)
Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite







#62 Raik

Raik

    Adventurer

  • Active Members
  • PipPip
  • 124 posts

Posted 30 May 2007 - 09:16 PM

decoder does not work for me. will use it for decoding http-auth

AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)


#63 ShaneHale

ShaneHale

    Seeker

  • Active Members
  • 31 posts

Posted 31 May 2007 - 12:02 AM

Just looking at theis encoder stuff... Has this evolved into something else? Does not seem to work with current versionm 3.2.4.9 - Gets an error about BinaryString. Did a search and replace to reflect it being renamed to Binary. Then I got another error:

C:\autoit_stuff\_Base64.au3 (258) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:


Would be useful if it worked again....

Thanks,
Shane

#64 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 31 May 2007 - 12:35 AM

Just looking at theis encoder stuff... Has this evolved into something else? Does not seem to work with current versionm 3.2.4.9 - Gets an error about BinaryString. Did a search and replace to reflect it being renamed to Binary. Then I got another error:
Would be useful if it worked again....

Thanks,
Shane

It is my belief that BinaryString was changed??

#65 Raik

Raik

    Adventurer

  • Active Members
  • PipPip
  • 124 posts

Posted 07 June 2007 - 05:52 PM

It is my belief that BinaryString was changed??

not "changed", just renamed. and if so, does it help, to reject, what ShaneHale wrote?
fixing the error will help.

AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)


#66 vrocco

vrocco

    Wayfarer

  • Active Members
  • Pip
  • 83 posts

Posted 17 July 2007 - 03:57 PM

I tried changing the BinaryString() calls to Binary() and it doesn't work. Won't decode correctly.

What can I do to use this?

#67 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 17 July 2007 - 04:04 PM

BinaryToString() and StringToBinary()
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

#68 vrocco

vrocco

    Wayfarer

  • Active Members
  • Pip
  • 83 posts

Posted 17 July 2007 - 04:20 PM

Hmmm.....I find that function in the help file, but Scite doesn't recognize it when I type it. Do I need some kind of #include to use it?

When I run the script with BinaryToString() replacing BinaryString() I get an unknown function error.

#69 vrocco

vrocco

    Wayfarer

  • Active Members
  • Pip
  • 83 posts

Posted 17 July 2007 - 05:15 PM

OK got that working finally. Now I get an error in line 258 "Array variable has incorrect number of subscripts or subscript dimension range exceeded."

How do I fix this?

#70 mikeytown2

mikeytown2

    Polymath

  • Active Members
  • PipPipPipPip
  • 210 posts

Posted 18 July 2007 - 03:32 AM

wow, never would have thought AutoIt would change that much.... anyway i fixed the example and core files.

Download New Files From Second Post


Incase anyone is looking for the old BinaryString() function i found this post...
http://www.autoitscript.com/forum/index.ph...mp;#entry367545

Edited by mikeytown2, 18 July 2007 - 03:39 AM.


#71 Celeri

Celeri

    Prodigy

  • Active Members
  • PipPipPip
  • 157 posts

Posted 18 July 2007 - 01:58 PM

wow, never would have thought AutoIt would change that much.... anyway i fixed the example and core files.

Download New Files From Second Post
Incase anyone is looking for the old BinaryString() function i found this post...
http://www.autoitscript.com/forum/index.ph...mp;#entry367545


Wow, good job!

I once wrapped my head around a base64 converter ... honestly that took a lot of effort to stay focused. Now I think I'm ready for the fifth dimension :whistle:

Be seeing you
I am endeavoring, ma'am, to construct a mnemonic circuit using stone knives and bearskins.SpockMy UDFs:Deleted - they were old and I'm lazy ... :)My utilities:Comment stripperPolicy lister 1.07AutoIT Speed Tester (new!)

#72 keed

keed

    Seeker

  • New Members
  • 2 posts

Posted 10 August 2007 - 03:04 PM

Hi, I wanted to use mikeytown2's _base64.au3 (from the latest "second post") but I found some preblems. Look, I am not a programmer and I appologise for some stupid things I may have said in this post. It was said that this .au3 supports binary files. Yes, but _Base64Encode() supports only input not containing null "charrachters" (#00). The problem is that this function (_Base64Encode()) uses '$as_Input = StringSplit($s_Input, "")' and when strigsplit() encounters a #00 it ends sudenly, resulting in a partial array. I tryed to encode a rar file, but because it included "null" bytes it ended prematuraly. Therefore , for my purposes I changed _base64.au3 so it could read directly from a file , byte by byte, in the array $as_Input. Then everything went OK.
I mean - found this problem, but if it is is discussed before or if what I say is a total scrap - please, don't mind it.

#73 mikeytown2

mikeytown2

    Polymath

  • Active Members
  • PipPipPipPip
  • 210 posts

Posted 27 August 2007 - 11:32 PM

Minor Update to Code
_Base64: Code Cleanup, I left in 2 ConsoleWrite functions and #include <Array.au3>. They are now removed. Updated documentation inside the file as well.

Grab files from second post.


keed what was your solution for reading binary files? This is what i came up with, just wondering if you had something different.
$file = "binaryfile.dat"
_Base64Encode (BinaryToString(FileRead(FileOpen($file, 16), FileGetSize($file))))
If you look in the example file that goes along with _base64.au3, it has the same solution as above.

#74 keed

keed

    Seeker

  • New Members
  • 2 posts

Posted 29 August 2007 - 01:13 PM

My solution was not a "solution" at all. I just wanted to see whether the function encodes correctly arbitrary binary files. (It does it of course.) I changed the _Base64Encode itself by adding this code:

Plain Text         
;Break the input up into bytes     ;startofmycode         Local $filesize = FileGetSize($filename)     Local $filearray[$filesize]               $filearray[0] = $filesize -1     $fhand = FileOpen($filename, 0)         for $i = 1 to $filesize - 1                 $filearray[$i] = FileRead($fhand, 1)     Next            Fileclose($fhand)         ;endofmycode ;Local $as_Input = StringSplit($s_Input, "")   &^(*&^(*&(*&(*UYO*&Y)         Local $as_Input = $filearray


And I added a parameter for the function called $filename.

As you see - it is very clumsy and it is only for testing purposes. Your solution is very fine.

#75 Armand

Armand

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 541 posts

Posted 15 December 2007 - 11:58 PM

GREAT UDF - WORKS LIKE A CHARM, THANKS!!
[why am i yelling ?!]

#76 Eddy

Eddy

    Seeker

  • New Members
  • 2 posts

Posted 26 December 2007 - 04:48 AM

I've seen many base64 decoder here and almost all of them are either too slow, too big, or decode incorrectly so I decided to write my own. Take a look for yourself and hopefully it'll help save you some time on base64 decoder. Any feedback is welcome. Happy programming...

Func Base64Decode($s)
Local $key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', _
$t = '', $p = -8, $a = 0, $c, $d, $len = StringLen($s)
For $i = 1 to $len
$c = StringInStr($key, StringMid($s,$i,1), 1) - 1
If $c < 0 Then ContinueLoop
$a = BitOR(BitShift($a, -6), BitAND($c, 63))
$p = $p + 6
If $p >= 0 Then
$d = BitAND(BitShift($a, $p), 255)
If $c <> 64 Then $t = $t & Chr($d)
$a = BitAND($a, 63)
$p = $p - 8
EndIf
Next
Return $t
EndFunc

#77 mikeytown2

mikeytown2

    Polymath

  • Active Members
  • PipPipPipPip
  • 210 posts

Posted 30 December 2007 - 03:03 AM

I've seen many base64 decoder here and almost all of them are either too slow, too big, or decode incorrectly so I decided to write my own. Take a look for yourself and hopefully it'll help save you some time on base64 decoder. Any feedback is welcome. Happy programming...

Func Base64Decode($s)     Local $key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', _     $t = '', $p = -8, $a = 0, $c, $d, $len = StringLen($s)     For $i = 1 to $len              $c = StringInStr($key, StringMid($s,$i,1), 1) - 1         If $c < 0 Then ContinueLoop             $a = BitOR(BitShift($a, -6), BitAND($c, 63))         $p = $p + 6         If $p >= 0 Then             $d = BitAND(BitShift($a, $p), 255)             If $c <> 64 Then $t = $t & Chr($d)             $a = BitAND($a, 63)             $p = $p - 8         EndIf     Next        Return $t EndFunc

This is a fairly simple decoder (i like), its slow though. It runs the for loop for every character. To decode a 155kb base64 file this took 12.763 seconds. With the decoder that me and blindwig made, it takes 0.767 seconds.

For our encoder/decoder, code size wasn't an issue; all we cared about was speed. This might be useful for someone who is trying to keep their code base very small.

#78 Uten

Uten

    stupid is as stupid does..

  • Active Members
  • PipPipPipPipPipPip
  • 1,989 posts

Posted 07 February 2008 - 10:40 PM

I think the line marked ;BUG?: is wrong (_INetSmtpMail.au3). My suggestion is in the code.
    ;Close Message and Connection     ;BUG?: For $i_Count = 0 To (UBound($as_Body) - 1) Step + 1     For $i_Count = 0 To (UBound($as_End) - 1) Step + 1         _SmtpSend($v_Socket, $as_End[$i_Count], $f_trace)         $s_Receive = _GetLastReplyMsg($v_Socket, $as_EndReplyCode[$i_Count], $f_trace)         If @error Then             SetError(60 + $i_Count)             Return False         EndIf     Next

I have noticed that the loop ain't the same as in the _INetSmtpMail with login support

Thanks for the nice work..:)
EDIT: You dont need my dbg lines..

Edited by Uten, 07 February 2008 - 10:44 PM.


#79 mikeytown2

mikeytown2

    Polymath

  • Active Members
  • PipPipPipPip
  • 210 posts

Posted 08 February 2008 - 03:16 AM

Uten, Thanks for your help! I know my SMTP code is quite messy. If you could take the first step and post a new version of the SMTP code, i would greatly appreciate it. As you suggested in your PM, there is code in the example file that should be in the UDF file. The ultimate goal would be for both files to be included as part of the official UDF's. I believe the base64 code is ready, the SMTP is not. I haven't played with the SMTP code for years.
Thanks for your Time!

#80 Tipulatoid

Tipulatoid

    Seeker

  • Active Members
  • 23 posts

Posted 29 October 2008 - 02:07 PM

I am sorry for simple question.
I have such file (grabbed e-mail attachment)
2_Slavinka4_per_7.zip.txt
I need to get binary zip-file. Tried different variants with no success.
Can you give example code? Thanks

Attached Files


Edited by Tipulatoid, 29 October 2008 - 02:19 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users