-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blowfish representation:hex to base64 #2
Comments
Hi @huisman, Do you have any examples you can show me? I tried converting a few samples of the generated hex code to base64 and the string output is longer, it seems. A simple "Hello, World!" with a key of Then converting to base64: $ echo "5689482A359F2AA08AEC0A4C0B19647EFED77C945C3B7EA3" | base64
NTY4OTQ4MkEzNTlGMkFBMDhBRUMwQTRDMEIxOTY0N0VGRUQ3N0M5NDVDM0I3RUEzCg== I also tried a paragraph of Lorem Ipsum with Maybe it depends on the key size and/or text, or perhaps I'm misunderstanding your question. Can you provide the sample you tried? Thanks, |
Hey @alfg, Simply converting a hex-string to base64 doesnt increase the number of bits per char, as the conversion treats the input sequence naively as a string. But since a hex char encodes 4 bits, and a base64 char 6 bits, we need to convert the hex string to a bit representation and then express that number in base64 in order to get to the shorter string. base64.js only features UTF* <-> base64 conversion, so I suppose we need to find/write a routine that converts hex-chars and put that in front of the blowfish.js in-/output. Is that more clear? I don't really know javascript, but I found one that appears to do what is required: http://en.ahotoke.com/tools/hexbase64.html Cheers! |
Alrighty. So I've added an implementation of converting Hex<->Base64 based off of the link you referred to. Thanks! Here is a sample: Compared to just the hex value: Seems much shorter now after a few tests. Thanks for your help on this. Let me know if if you see any problems with the implementation. Alf |
A that's great! The URLs are shorter here too. Nice work! Small detail: perhaps it'd be nice that after you press Decrypt the regular Save/Clear/Add key buttons return. |
Thanks for testing it out! The Clear button will make the regular buttons return. I leave the Decrypt button there for when you try decrypting with the wrong key, you won't have to refresh to try again. I haven't thought of a way to validate if the decryption was successful or not. |
The downside is that currently you need to copy, clear and paste to edit a protected text. You could add a second control char (after e) but ecrypted with the key. If after decryption this char is correct, you'll be good to go. |
Thanks for the suggestion. I will look into this. |
I discovered a bug that shows on messages of (at least) 1420 chars (I havent pinned down the exact number) that are encrypted. After decryption the last character of the original message is missing. |
Thanks, looking into this. I noticed it happens on some shorter messages after playing around with some variations. Not sure what is causing it yet. http://alfg.co/jot/#bYwoTigrPd6TpdG4Z2+3p9hMv3b9w+Zrt (key=test) It cuts off the trailing e in message. |
Hi @alfg, About the bug, I tried this code. for (var i = 1, bf = new Blowfish("test"), a = []; i < 50; ++i)
if (bf.decrypt(bf.encrypt(Array(i + 1).join("a"))).length !== i)
a.push(i);
alert(a); //1,9,17,25,33,41,49 I guess that blowfish.js cause this bug when a number of characters is 8 * n + 1. |
Thank you, @imu0x10! I will test out this library later tonight. |
Hi @imu0x10 and @huisman, http://alfg.co/jot/ is now up to date with the updated blowfish.js library mentioned above and is also using the encrypt64/decrypt64 methods as well. The issue seems to be fixed for some samples I've tried. Go ahead and give it a shot and close ticket or respond if you still have any issues. Thanks again! |
Excellent, the bug seems to be gone now! Thanks @imu0x10, @alfg! |
Currently an encrypted message takes up twice the numbre of chars as an unencrypted message, due to the hex representation of the former versus base64 for the latter. In order to save some chars, it'd be nice to convert the hex to base64 and back.
The text was updated successfully, but these errors were encountered: