Skip to content

Simple function to works with base64 encoding

This is simple function, it useful for base64 encoding

masgim

Created by / masgim

JS
const Base64 = {
    encode: (str) {
        return Buffer.from(str).toString('base64)
    },
    decode: (base64) {
        return Buffer.from(base64, 'base64').toString('utf-8')
    }
}

const encoded = Base64.encode('anjay slur') // YW5qYXkgc2x1cg==
const decoded = Base64.decode('YW5qYXkgc2x1cg==') // anjay slur