mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-12-29 16:16:02 +00:00
8 lines
283 B
TypeScript
8 lines
283 B
TypeScript
export function rot13(input: string): string {
|
|
return input.replace(/[a-zA-Z]/g, (char) => {
|
|
const charCode = char.charCodeAt(0);
|
|
const baseCode = charCode >= 97 ? 97 : 65; // 'a' or 'A'
|
|
return String.fromCharCode(((charCode - baseCode + 13) % 26) + baseCode);
|
|
});
|
|
}
|