A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Rot13 in Typescript page! Here, you'll find the source code for this program as well as a description of how the program works.
function rot13(input: string): string {
if (!input) {
return "Usage: please provide a string to encrypt";
}
return input.split('').map(char => {
const code = char.charCodeAt(0);
// Check if the character is an uppercase letter
if (code >= 65 && code <= 90) {
return String.fromCharCode((code - 65 + 13) % 26 + 65);
}
// Check if the character is a lowercase letter
else if (code >= 97 && code <= 122) {
return String.fromCharCode((code - 97 + 13) % 26 + 97);
}
// If it's not a letter, return the character unchanged
return char;
}).join('');
}
const args = process.argv.slice(2);
if (args.length !== 1) {
console.log("Usage: please provide a string to encrypt");
process.exit(1);
} else {
const input = args[0];
const result = rot13(input);
console.log(result);
}
Rot13 in Typescript was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.