Created
January 9, 2016 23:28
-
-
Save JavaScript-Packer/bbf68a4dc0e1fd102221 to your computer and use it in GitHub Desktop.
JavaScript LZW Compression (encode and decode functions). Lempel–Ziv–Welch (LZW) is a universal lossless data compression algorithm created by Abraham Lempel, Jacob Ziv, and Terry Welch. It was published by Welch in 1984 as an improved implementation of the LZ78 algorithm published by Lempel and Ziv in 1978. The algorithm is simple to implement,…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function en(c) { | |
var x = "charCodeAt", b, e = {}, f = c.split(""), d = [], a = f[0], g = 256; | |
for (b = 1; b < f.length; b++) c = f[b], null != e[a + c] ? a += c :(d.push(1 < a.length ? e[a] :a[x](0)), | |
e[a + c] = g, g++, a = c); | |
d.push(1 < a.length ? e[a] :a[x](0)); | |
for (b = 0; b < d.length; b++) d[b] = String.fromCharCode(d[b]); | |
return d.join(""); | |
} | |
function de(b) { | |
var a, e = {}, d = b.split(""), c = f = d[0], g = [ c ], h = o = 256; | |
for (b = 1; b < d.length; b++) a = d[b].charCodeAt(0), a = h > a ? d[b] :e[a] ? e[a] :f + c, | |
g.push(a), c = a.charAt(0), e[o] = f + c, o++, f = a; | |
return g.join(""); | |
} | |
var compressed=en("http://www.ScriptCompress.com - Simple Packer/Minify/Com\ | |
press JavaScript Minify, Fixify & Prettify 75 JS Obfuscators In 1 App 25 JS\ | |
Compressors (Gzip, Bzip, LZMA, etc) PHP, HTML & JS Packers In 1 App PHP So\ | |
urce Code Packers Text Packer HTML Packer or v2 or v3 or LZW Twitter Compre\ | |
ss or More Words DNA & Base64 Packer (freq tool) or v2 JS JavaScript Code G\ | |
olfer Encode Between Quotes Decode Almost Anything Password Protect Scripts\ | |
HTML Minifier v2 or Encoder or Escaper CSS Minifier or Compressor v2 SVG I\ | |
mage Shrinker HTML To: SVG or SVGZ (Gzipped) HTML To: PNG or v2 2015 JS Pac\ | |
ker v2 v3 Embedded File Generator Extreme Packer or version 2 Our Blog Demo\ | |
Scene JS Packer Basic JS Packer or New Version Asciify JavaScript Escape Ja\ | |
vaScript Characters UnPacker Packed JS JavaScript Minify/Uglify Text Splitt\ | |
er/Chunker Twitter, Use More Characters Base64 Drag 'n Drop Redirect URL Da\ | |
taURI Get Words Repeated LZMA Archiver ZIP Read/Extract/Make BEAUTIFIER & C\ | |
ODE FIXER WHAK-A-SCRIPT JAVASCRIPT MANGLER 30 STRING ENCODERS CONVERTERS, E\ | |
NCRYPTION & ENCODERS 43 Byte 1px GIF Generator Steganography PNG Generator \ | |
WEB APPS VIA DATAURL OLD VERSION OF WHAK PAKr Fun Text Encrypt Our Google"); | |
var decompressed = de(compressed); | |
document.writeln("<hr>Compressed " + compressed + "<hr><h1>" + compressed.length + " characters versus original uncompressed " + decompressed.length + " characters.</h1><hr>" + decompressed + "<hr>"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Minified versions: