ROT13 Encode/Decode

Encode or decode a string using the ROT13 cipher, where the same operation is used for both encoding and decoding.

Code

Utilities
str.replace(/[a-zA-Z]/g, c => String.fromCharCode((c <= 'Z' ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26));

Parameters

The string to encode/decode.

Browser·fetch() may be limited by CORS

More JavaScript Snippets