blowfish.js icon indicating copy to clipboard operation
blowfish.js copied to clipboard

Padding

Open bored-engineer opened this issue 14 years ago • 1 comments

A weird issue has come up recently where the padding seems to be messed up.

To replicate: var me = new Blowfish("me"); var Data = me.encrypt("stuff"); alert(me.decrypt(Data));

It should alert "stuff" but instead its "stuff000"

I wrote this simple addon for the decrypt function to fix it:

//Patch by me to remove trailing zeros
returndata = this.unescape(dec);
revertext = returndata.split("").reverse();
for(i=0;i<8;i++){
  if(revertext[i] == "0"){
    delete revertext[i];
  }
}
returndata = revertext.reverse().join("");*
return returndata;

but it is obviously not ideal.

bored-engineer avatar May 15 '11 04:05 bored-engineer

I just checked this against the "marcelgreter" branch (https://github.com/drench/blowfish.js/tree/marcelgreter) and that version does not have the padding problem. Give that version a try if you don't need compatibility with Perl's Crypt::Blowfish.

drench avatar May 15 '11 13:05 drench