We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent aba0cb2 commit 481ad62Copy full SHA for 481ad62
1 file changed
ciphers/rot13.js
@@ -0,0 +1,18 @@
1
+// JavaScript implementation of ROT13
2
+//
3
+// Author: NIEZWAN ABDUL WAHID
4
+
5
+function rot13(str) {
6
+ var string = [];
7
8
+ for (var i = 0; i < str.length; i++) {
9
+ if ((str.charCodeAt(i) > 77 && str.charCodeAt(i) <= 90) || (str.charCodeAt(i) > 109 && str.charCodeAt(i) <= 122)) {
10
+ string.push(String.fromCharCode(str.charCodeAt(i) - 13));
11
+ } else {
12
+ string.push(String.fromCharCode(str.charCodeAt(i) + 13));
13
+ }
14
15
+ return string.join("");
16
+}
17
18
+// rot13("hello") == "uryyb"
0 commit comments