-
Notifications
You must be signed in to change notification settings - Fork 8
Cleanup Base64 weirdness in User #2
Comments
thats strange, could you try with this login function?
|
Yup! Same thing. Stacktrace below:
Interestingly, if I add a character to my username (taking it from 21 characters to 22 characters) I just get an (expected)
I'll try changing my Cohost account to use an email with an extra character in - if that works, it's just wrangling the base64 function into working. There's also a great writeup by @iliana who's implemented this in eggbug.rs - I'm going to try to find time and port this b64 function into Python (I tried it with JS but my brain and JavaScript just Do Not Collaborate) |
got it! we have to replace "_" and "-" with just "A" or it breaks - code sample as follows [...]
salt = fetch("GET", "/login/salt", {"email": email})['salt']
salt = salt.replace('-', 'A')
salt = salt.replace('_', 'A')
salt = salt + "=="
[...] i'll work on pushing out a new version now :) thanks so much for the PR! |
Ok! Pushed the changes, and I've published a new version to pypi. I'll close this, but, if we have issues again with login, I'll reopen this issue. release link: https://github.com/valknight/Cohost.py/releases/tag/release%2F0.2.0 |
oh! i’ve seen this as a possible solution, didnt think it was the issue as my salt didn’t contain that. using |
ah! let me try that real quick :) |
Yeah, that hits me with good friend I'll keep this issue open, but I'll change the title to "clean up base64 weirdness", considering login stuff is now working 😄 |
i think you may have already seen this, but iliana had a good writeup on What Specific Base64 Bullshit is going on (spoiler: it's a join inaccuracy between sodium and the client-side arraybuffer library we use, that we never noticed because they're both broken in the same way) but the good news is the workaround isn't that bad, just dumb, and already mostly described in this thread https://cohost.org/iliana/post/180187-eggbug-rs-v0-1-3-d EDIT LIKE A MINUTE LATER: wait i'm a dumbass and just saw that y'all already solved this. ignore everything i said and keep up the good work |
Spawned from PR by @CrCrate - #1
Error when logging in ,specifically in decoding base64 - erorr is
binascii.Error: Invalid base64-encoded string: number of data characters (21) cannot be 1 more than a multiple of 4
EDIT: This is now solved, but, I'm keeping the issue open to have a mental note to come back and clean this up at some point.
The text was updated successfully, but these errors were encountered: