Skip to content

Instantly share code, notes, and snippets.

@ivlists
Forked from vicmortelmans/gist:1391229
Last active July 17, 2017 21:00
Show Gist options
  • Save ivlists/5002519 to your computer and use it in GitHub Desktop.
Save ivlists/5002519 to your computer and use it in GitHub Desktop.
Blowfish encryption library implementation for Google app scripts (Precisely - Docs).
function escape(t)
{
var r='';
for(var i=0;i<t.length;i++){
var c=t.charCodeAt(i);
var t1=Math.floor(c/16);
var t2=c%16;
if (t1<10) t1+=48;
else t1+=55;
if (t2<10) t2+=48;
else t2+=55;
r+=String.fromCharCode(t1)+String.fromCharCode(t2);
}
return r;
};
function unescape(t)
{
var r='';
for(i=0;i<t.length;i++){
var t1=t.charCodeAt(i++);
var t2=t.charCodeAt(i);
if (t1<58) t1-=48;
else {
if (t1>96) t1-=87;
else t1-=55;
}
if (t2<58) t2-=48;
else {
if (t2>96) t2-=87;
else t2-=55;
}
r+=String.fromCharCode(t1*16+t2);
}
return r;
};
@volomike
Copy link

Your gist isn't Blowfish. It's ASCII shifting. However, your "complete implementation of this script" link above appears to be far more elaborate than this Gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment