Помогите решить функцию JavaScript

function hexToASCII(hex) {
  let ascii = '';
  for (let i = 0; i < hex.length; i += 2) {
    ascii += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
  }
  return ascii;
}

function MyBirthdayQuiz(decryptFunc, encryptedMessage) {
  const decryptedMsg = decryptFunc(encryptedMessage);
  const decryptedJSON = JSON.parse(decryptedMsg);
  return `My birthday is: ${decryptedJSON.month} ${decryptedJSON.day}, ${decryptedJSON.year}`;
}

function marsDecrypt(encryptedMsg) {
  const hexMsg = hexToASCII(encryptedMsg);
  let decryptedMsg = '';

  const key = 'E'.charCodeAt(0) ^ 'n'.charCodeAt(0);

  for (let i = 0; i < hexMsg.length; i++) {
    decryptedMsg += String.fromCharCode(hexMsg.charCodeAt(i) ^ key);
  }

  return decryptedMsg;
}

const encryptedMessage = "192c634762302c34623b6c302c7b6c6a3b7d";

console.log(MyBirthdayQuiz(marsDecrypt, encryptedMessage));


Ответы (0 шт):