JSFiddle - React, Tailwind, and code Playground

by de Montalembert Jonathan

JavaScript

function encrypt(str, key) {
	const num = str.split("").map(c => c.charCodeAt(0) + 1).reduce((val, acc) => acc + val, 0)
  return key.split("").map(c => String.fromCharCode(c.charCodeAt(0) + num)).join("")
}

function decrypt(str, key) {
	const num = str.split("").map(c => c.charCodeAt(0) + 1).reduce((val, acc) => acc + val, 0)
}

console.log(encrypt("errol", "dgfhhytr98df6guhrdg"))