rot13
This rot13 tag encodes and decodes text by shifting letters 13 positions in the alphabet.
Created by: hackvertor
Installed 1 times
Category: Encrypt
Created on: Monday, October 21, 2024 at 8:32:22 PM
Updated on: Sunday, November 3, 2024 at 12:07:01 PM
Tag arguments
[]
Code
class rot13 {
encode(input) {
return input.replace(/[a-zA-Z]/g, (char) => {
const start = char <= "Z" ? 65 : 97;
return String.fromCharCode(
((char.charCodeAt(0) - start + 13) % 26) + start,
);
});
}
}