Skip to content

Commit

Permalink
Added JS lib
Browse files Browse the repository at this point in the history
  • Loading branch information
arguiot committed Feb 20, 2018
1 parent 00cd355 commit e9d1347
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
34 changes: 34 additions & 0 deletions js/decrypt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*****************************
Use: "H3ll0 W0rld!".decrypt()
=> "Hello World!"
*****************************/

const l33t = {
"a": 4,
"e": 3,
"g": 6,
"i": 1,
"o": 0,
"s": 5,
"t": 7,
"A": 4,
"E": 3,
"G": 6,
"I": 1,
"O": 0,
"S": 5,
"T": 7
}

String.prototype.decrypt = function () {
let out = this
for (let i in l33t) {
const reg = new RegExp(l33t[i].toString(), "gi")
out = out.replace(reg, i)
}
return out
};

module.exports = text => text.decrypt()
34 changes: 34 additions & 0 deletions js/encrypt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*****************************
Use: "Hello World!".encrypt()
=> "H3ll0 W0rld!"
*****************************/

const l33t = {
"a": 4,
"e": 3,
"g": 6,
"i": 1,
"o": 0,
"s": 5,
"t": 7,
"A": 4,
"E": 3,
"G": 6,
"I": 1,
"O": 0,
"S": 5,
"T": 7
}

String.prototype.encrypt = function () {
let out = this
for (let i in l33t) {
const reg = new RegExp(i, "gi")
out = out.replace(reg, l33t[i].toString())
}
return out
};

module.exports = text => text.encrypt()
13 changes: 13 additions & 0 deletions js/lib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**********************
Simple bridge
**********************/

const encrypt = require("./encrypt")
const decrypt = require("./decrypt")

module.exports = {
encrypt: encrypt,
decrypt: decrypt
}

0 comments on commit e9d1347

Please sign in to comment.