jstrieb / link-lock

Password-protect URLs using AES in the browser; create hidden bookmarks without a browser extension
https://jstrieb.github.io/link-lock
MIT License
860 stars 159 forks source link

Suggestions: use window.atob instead of b64.js #4

Closed acutmore closed 4 years ago

acutmore commented 4 years ago

Cool concept!

One idea, if you hadn't already considered, is to use the built-in atob function instead of loading a custom base-64 library.

jstrieb commented 4 years ago

Thanks for checking out the project!

I originally used atob and btoa with this and another project,1 but for both projects quickly ran into the "Unicode Problem" with those functions.2 In this case, since I am directly encoding bytes from the SubtleCrypto API, rather than Unicode code points, none of the solutions I could find apply. The only existing solutions that I could find involved using external base-64 libraries for encoding arbitrary bytes. In this case, I just decided to write my own base-64 library instead of pulling in an external one.

Thanks again for taking the time to look at the code!

1 https://github.com/jstrieb/urlpages

2 See this StackOverflow post

acutmore commented 4 years ago

Today I learn about the "Unicode Problem" with atob, thank you!

jstrieb commented 4 years ago

Today I learn about the "Unicode Problem" with atob, thank you!

Hopefully knowing this is helpful. It took me way too long to figure out because I never suspected that the built-in functions would be the problem! Thanks again for your suggestion!