Files
omni-tools/src/pages/tools/string/rot13/service.ts
Ibrahima G. Coulibaly 2dc78e7392 chore: merge
2025-03-07 22:19:49 +00:00

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);
});
}