Similar to urlsafe-base64 this library de-/encodes urlsafe base64 strings.
What it does different:
- Offers a
safe
andshort
variant with theshort
variant being same asurlsafe-base64
and thesafe
variant keeping the ending=
characters making it compatible with other implementations such as python. - Comes with typescript definitions.
- Uses
Buffer.from
asnew Buffer
has been deprecated for a long time.
import { short, safe } from '@tradle/urlsafe-base64'
;[ short, safe ].forEach(variant => {
const base64Str = short.encode('hello')
const decoded = short.decode(base64Str)
const original = decoded.toString()
})