Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Include a bitmap in your uncompiled script!!!


  • Please log in to reply
84 replies to this topic
Veovis
  • Members
  • 389 posts
  • Last active: Mar 17 2009 12:24 AM
  • Joined: 13 Feb 2006

An uncompiled script can be used as a Self-extracting archive :!: 8) 8)


Thats a great idea! Provide someone with a script to downlaod. For example: script.ahk, which when run simply replaces itself with a different script, as well as a bunch of images, exes, dll, etc, whatever you want.
Posted Image
"Power can be given overnight, but responsibility must be taught. Long years go into its making."

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
You are right, from the length of the coded message you can reconstruct the "=" or "==". I guess the standard has them, so you don't need to know the length. If I interpreted the standard wrong, I have to revise the original scripts, too. Can you find "official" test data?

I checked Mod(StrLen(code),4), which is the same as "&3", masking the LS 2 bits.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

What is the advantage of using "standard" encoding here?

You can copy into the script already encoded files, like email attachments.

Well, not a paramount advantage, if you have programs to encode or decode. Using an e-mail client to encode a file is, well, rather clumsy... :-)
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

Concerning Pebwa, while i think it is a great idea, i am not near advanced enough to fully understand how it works and since it leaves all normal chars alone, it does not encode the hexadecimal.

Here, I don't follow you. I thought the base idea is to encode binary data to plain Ascii (or Ansi), to be able to include it in a script (or transmit it over 7bit protocols, like the original e-mail use).
Hexadecimal is already Ascii, so I don't see why you need to encode it.
Base64, Ascii85, Pebwa are all made to process binary data, so there is no need to first generate hexa.
If I missed the point, let me know, thank you.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
FYI: Morello axsBlob Component

Price FREE Download axsblob.zip Version 1.0 (141 KB)

axsBlob is a simple but flexible COM component which acts as a container for a Binary Large OBject (BLOB). Blobs typically contain large binary resources, such as images, movie clips etc.

Raw binary data can be problematic in some environments, such as ASP or VBScript, but when the data is held in an axsBlob object it can be passed around much more easily.

axsBlob provides methods to read or write the Blob data as an array, string, hex string, file, or IStream. This provides a flexible point of conversion – data can be read in from a file and written out again as a string, etc.

That's Com, so currently not usable directly in AHK, but a simple VBScript can use it.
They also wrote a PDF whitepaper document on binary encoding (link found in the Wikipedia page).

Oh, they also have a Windows scripting language: Clam. Looks limited, but its idea to show program as a visual tree is interesting.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

Veovis
  • Members
  • 389 posts
  • Last active: Mar 17 2009 12:24 AM
  • Joined: 13 Feb 2006

Base64, Ascii85, Pebwa are all made to process binary data, so there is no need to first generate hexa.


Ah, you are right of course. That it was i meant when i said this is all a little above me. While i do grasp some of the basic concepts of Pebwa I dont fully understand how it works. Dont get me wrong, you did a great job of explaining how it works in that topic, but i just couldnt quite get my mind around the code. I was quite proud when i was able to make Base64 work for me.

So at the moment, i think what i want is simply what ever can compress data the best and fastest. For use in including files in uncomplied scripts, while taking the least amount of space possible.
Posted Image
"Power can be given overnight, but responsibility must be taught. Long years go into its making."

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005

[copy into the script already encoded files] Well, not a paramount advantage, if you have programs to encode or decode. Using an e-mail client to encode a file is, well, rather clumsy... :-)

What I meant was that often you have your data already in MIME (if received in email). You don't use an email client to encode, just take what you already got.

Base64, Ascii85, Pebwa are all made to process binary data, so there is no need to first generate hexa.

Sometimes there is. If you create/process binary data in an AHK script, the easiest is in hex, because pairs of digits correspond to bytes. Take the example of the scrolling tray icon. The hex stream can be processed as a string, there is no need to resort to ugly dll calls. If you have your data in hex, you could convert it to binary and then to Base64, or do it directly.

what ever can compress data the best and fastest.

Unfortunately, it depends on the data. If your file happens to contain only printable ANSI, you don't need to encode it. The most compact data is achieved probably with first compressing the binary (zip, rar, jpg...) then Ascii85. With pre- and post processing, you could improve on it, if you don't want to keep it standard: 7 printable 7-bit ASCII characters v, w, x, y, {, |, } are not used, so you scan the already Ascii85 encoded data for repeated patterns, and replace them with one of the free chars, adding the translation info in the front.

Also, the Base64 codec is simple and fast. Functions for more complex codes are longer (and slower), so what you gain in the size of the encoded data, you could loose in code size.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

If you have your data in hex, you could convert it to binary and then to Base64, or do it directly.

Ah, OK, I thought Veovis was encoding in Base64 the hex data itself! Which would have inflated the data by 2 * 1.33! And would have been unecessary. Sorry, it was dumb.
And you make a point with the simplicity of Base64, Pebwa's slowness is obvious when processing more than 20KB (but it isn't a good idea to store large data in Ascii form anyway. That's more for small images, etc.).
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
I posted simple functions for Ascii85 en/decoding binary buffers. They are only slightly slower and more complex than Base64, so they provide an alternative. Pebwa could still provide smaller encoded data, because it uses 8-bit ANSI, while Base64 and Ascii85 use 7-bit ASCII. ASCII might be safer for some environments.

Grounded Veovis
  • Guests
  • Last active:
  • Joined: --
Nice work Laszlo, i would look into that in more detail but unfortunately i got grounded and my laptop was taken away, which had all my code and projects on it. So i might not be posting for a couple weeks. :cry:

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
You must have been really naughty. PM me the email address of your parents, maybe I can reason with them.

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004
As expected, there are a few bugs with the encrypt/decrypt functions I posted recently that could prevent some files from decrypting properly. I'll post an updated version in a new topic in a few days in case anyone is interested :) .

robiandi
  • Guests
  • Last active:
  • Joined: --
@corrupt: All are interested.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
@corrupt: Me too :D
kWo4Lk1.png

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

As expected, there are a few bugs with the encrypt/decrypt functions I posted recently that could prevent some files from decrypting properly. I'll post an updated version in a new topic in a few days in case anyone is interested :) .

Updated versions of the functions can be found here :) .