namastejs
Version:
A spiritual greeting from your JavaScript code. Because every function deserves a 'Namaste 🙏'
16 lines (13 loc) • 412 B
JavaScript
function encode(str, salt = 7) {
return Buffer.from(
str.split("").map(char => String.fromCharCode(char.charCodeAt(0) + salt)).join("")
).toString("base64");
}
function decode(encoded, salt = 7) {
return Buffer.from(encoded, "base64")
.toString()
.split("")
.map(char => String.fromCharCode(char.charCodeAt(0) - salt))
.join("");
}
module.exports = { encode, decode };