I've created a script for base64 encryption. That includes binary conversions, since those are required for bse64. The binary conversions do work as far as I have tested. It only does numbers, because that's what is going to be converted to and from binary.
The problem is not a syntax/javascript error, but just inproper output. I believe the problem to be in the decryption, but it may be in the encryption. I'm pretty sure it is just something stupid that I overlooked. I've gone through the script several times and done tests, but they didn't help. The script is pretty well commented and can be found here:
http://digitalcs.net/tests/enc.htm