Skip to content
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

Implementation has some flaws #3

Open
David263 opened this issue Oct 24, 2018 · 1 comment
Open

Implementation has some flaws #3

David263 opened this issue Oct 24, 2018 · 1 comment

Comments

@David263
Copy link

  1. The use of fromCharCode() is incorrect. It requires four 16-bit values (Unicode), not four 8-bit values (UTF-8).

  2. The algorithms are not compact. For example, here is a more compact base64 encoder:

base64Encode = function(str) {
if (typeof btoa != 'undefined') return btoa(str); // browser
if (typeof Buffer != 'undefined') return new Buffer(str, 'binary').toString('base64'); // Node.js
throw new Error('No Base64 Encode');
};

@andot
Copy link
Member

andot commented Oct 24, 2018

  1. I don't think the use of fromCharCode() is incorrect. Because btoa and atob function use 8-bit binary string, not 16-bit Unicode String.

  2. This version is compatible with IE6-IE9. If you are only used for IE10+ or other modern browsers, you can use https://github.com/xxtea/xxtea-html5. if you are used for Node.js, you can use https://github.com/xxtea/xxtea-nodejs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants