Created
February 19, 2022 17:10
-
-
Save davidsharp/77ff8bda7a07c488e1027da3987b9cb6 to your computer and use it in GitHub Desktop.
Dirty little ROT13 function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rot13 = str => str.replace(/[a-z]/gi,x=>{ | |
const c=x.charCodeAt(0) | |
const a=c>=97?97:65 | |
return String.fromCharCode( | |
a+((c-a+13)%26) | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment