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

Error Not a base64-encoded string #2

Open
simarilius opened this issue Jun 4, 2014 · 0 comments
Open

Error Not a base64-encoded string #2

simarilius opened this issue Jun 4, 2014 · 0 comments

Comments

@simarilius
Copy link

Works fine :)
Found a small issue for my case:
encryption in php -> decryption in javascript

Sometime I get an error: Not a base64-encoded string

Was a simple to fix:
Crypt.php changes Characters after base64_encode:

strtr($sBase64, '+/', '-_');

This has to be undone in crypt.js:
function decode64(text) {

text = text.replace(/\s/g, "");
text = text.replace(/-/g, '+');
text = text.replace(/_/g, '/');
if (!(/^[a-z0-9+/\s]+={0,2}$/i.test(text)) || text.length % 4 > 0) {
alert("Not a base64-encoded string.");
}

Most likely the same issue is in encode64

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

1 participant