Giter Club home page Giter Club logo

crispy's Introduction

crispy

Simple Python Script Packer

build works-on pizza-rolls

crispy is a small and simple Python script packer intended to be used in size-coding challenges. It uses dictionary compression to compact the script down to a small string, which is decoded and executed once the minified program is run. The packer itself is fully self-contained and doesn't require any additional packages beyond a basic python install.

Usage

usage: cris.py [-mlxfvh] [-o outfile] infile

a small and simple Python script packer

  infile         specify the input file
  -o outfile     specify the output file

  -m, --minify   minify python script before compressing
  -l, --latin1   allow extended ascii chars as placeholders
  -x, --hex      turn rare chars into hex numbers (experimental)
  -f, --fast     enable fast compression mode for testing purposes
  -v, --verbose  increase verbosity level (can be set multiple times)
  -h, --help     show this help message and exit

Example

In the following example, we want to compress the file "input.py" and store the result in "output.py". We are going to use the following command:

python cris.py input.py -o output.py -m -vv

The "input.py" file in our example looks like this:

print("Hello, hello!")

And the "output.py" file ended up looking like this:

c='print("H~, h~!")~ello'
for i in'~':c=c.split(i);c=c.pop().join(c)
exec(c)

Note: The packer ended up increasing the size of the script, as the input file given in this example was already very small. Because the packer comes with some overhead, it is only really effective, when compressing files in the range of a few kilobytes.

Extra Credit

This project is heavily inspired by RegPack, a javascript packer developed by Siorki. Go check out that GitHub repo if you haven't already: https://github.com/Siorki/RegPack

crispy's People

Contributors

slerpyyy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

icodein

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.