dcodeIO / bcrypt.js

Optimized bcrypt in plain JavaScript with zero dependencies.
Other
3.47k stars 264 forks source link

Base64 encoding/decoding use native atob/btoa if available #72

Closed Ruffio closed 6 years ago

Ruffio commented 6 years ago

Cool project, that I'm going to use :-)

I have been looking thru the code and can see that some kind of Base64 encoding/decoding is used. Would it be an idea to use atob/btoa if available with a fallback to the currently implemented method if not? According to 'Can I Use' then all major browsers have these implemented and supported. It has been for many versions (https://caniuse.com/#search=atob):

image

dcodeIO commented 6 years ago

bcrypt's base64 alphabet differs from what is considered the standard. Hence it has its own implementation. Also note that atob/btoa does not work well with binary data.

Ruffio commented 6 years ago

Is that because bcrypt was originally developed before 'the standard' became the standard ?

dcodeIO commented 6 years ago

I am not aware of the historical background, unfortunately.