HEX
Server: LiteSpeed
System: Linux CentOS-79-64-minimal 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: vishn3436 (5293)
PHP: 8.0.15
Disabled: NONE
Upload Files
File: //opt/bitninja-dispatcher/node_modules/ebg13/index.js
function convertToCharCode(c) {
  return c.charCodeAt();
}

function convertToChar(c) {
  return String.fromCharCode(c);
}

function rotateBy(key) {
  return function rotate(c) {
    if (c >= 65 && c <= 90) {
      return (c + key <= 90) ? c + key : c + key - 90 + 64;
    } else if (c >= 97 && c <= 122) {
      return (c + key <= 122) ? c + key : c + key - 122 + 96;
    }

    return c;
  };
}


function rot13(message, key = 13) {
  if (typeof message !== 'string') {
    return '';
  }

  const rotate = rotateBy(key);

  return message.split('').map(convertToCharCode).map(rotate).map(convertToChar)
    .join('');
}

module.exports = rot13;