email-scramble
Advanced tools
Comparing version 1.0.1 to 2.0.0
@@ -1,1 +0,1 @@ | ||
{"/Users/will/Projects/email-scramble/email-scramble.js":{"path":"/Users/will/Projects/email-scramble/email-scramble.js","s":{"1":1,"2":1,"3":0,"4":1,"5":1,"6":0,"7":1,"8":258,"9":258,"10":258,"11":258,"12":258,"13":1,"14":258,"15":258,"16":258,"17":10,"18":248,"19":110,"20":248,"21":248,"22":248,"23":248,"24":248,"25":248,"26":248,"27":22558,"28":22558,"29":6352,"30":6352,"31":6352,"32":16206,"33":6188,"34":6188,"35":6188,"36":10018,"37":248,"38":1,"39":82,"40":86,"41":1,"42":82,"43":86,"44":1},"b":{"1":[0,1],"2":[1,0],"3":[1,0],"4":[1,257],"5":[10,248],"6":[110,138],"7":[6352,16206],"8":[6188,10018]},"f":{"1":1,"2":1,"3":258,"4":82,"5":86,"6":82,"7":86},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":26}}},"2":{"name":"(anonymous_2)","line":10,"loc":{"start":{"line":10,"column":8},"end":{"line":10,"column":24}}},"3":{"name":"rot","line":14,"loc":{"start":{"line":14,"column":12},"end":{"line":14,"column":33}}},"4":{"name":"encoder","line":57,"loc":{"start":{"line":57,"column":16},"end":{"line":57,"column":36}}},"5":{"name":"encode","line":58,"loc":{"start":{"line":58,"column":11},"end":{"line":58,"column":32}}},"6":{"name":"decoder","line":63,"loc":{"start":{"line":63,"column":16},"end":{"line":63,"column":36}}},"7":{"name":"decode","line":64,"loc":{"start":{"line":64,"column":11},"end":{"line":64,"column":32}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":74,"column":4}},"2":{"start":{"line":3,"column":2},"end":{"line":9,"column":3}},"3":{"start":{"line":4,"column":4},"end":{"line":4,"column":44}},"4":{"start":{"line":5,"column":9},"end":{"line":9,"column":3}},"5":{"start":{"line":6,"column":4},"end":{"line":6,"column":35}},"6":{"start":{"line":8,"column":4},"end":{"line":8,"column":39}},"7":{"start":{"line":14,"column":2},"end":{"line":55,"column":4}},"8":{"start":{"line":16,"column":4},"end":{"line":16,"column":49}},"9":{"start":{"line":17,"column":4},"end":{"line":17,"column":49}},"10":{"start":{"line":18,"column":4},"end":{"line":18,"column":33}},"11":{"start":{"line":19,"column":4},"end":{"line":19,"column":33}},"12":{"start":{"line":21,"column":4},"end":{"line":24,"column":5}},"13":{"start":{"line":23,"column":6},"end":{"line":23,"column":13}},"14":{"start":{"line":25,"column":4},"end":{"line":25,"column":18}},"15":{"start":{"line":26,"column":4},"end":{"line":26,"column":22}},"16":{"start":{"line":27,"column":4},"end":{"line":29,"column":5}},"17":{"start":{"line":28,"column":6},"end":{"line":28,"column":17}},"18":{"start":{"line":30,"column":4},"end":{"line":32,"column":5}},"19":{"start":{"line":31,"column":6},"end":{"line":31,"column":14}},"20":{"start":{"line":33,"column":4},"end":{"line":33,"column":28}},"21":{"start":{"line":34,"column":4},"end":{"line":34,"column":19}},"22":{"start":{"line":35,"column":4},"end":{"line":35,"column":20}},"23":{"start":{"line":36,"column":4},"end":{"line":36,"column":18}},"24":{"start":{"line":37,"column":4},"end":{"line":37,"column":24}},"25":{"start":{"line":38,"column":4},"end":{"line":38,"column":24}},"26":{"start":{"line":39,"column":4},"end":{"line":52,"column":5}},"27":{"start":{"line":40,"column":6},"end":{"line":40,"column":36}},"28":{"start":{"line":41,"column":6},"end":{"line":51,"column":7}},"29":{"start":{"line":42,"column":8},"end":{"line":42,"column":55}},"30":{"start":{"line":43,"column":8},"end":{"line":43,"column":53}},"31":{"start":{"line":44,"column":8},"end":{"line":44,"column":52}},"32":{"start":{"line":45,"column":13},"end":{"line":51,"column":7}},"33":{"start":{"line":46,"column":8},"end":{"line":46,"column":55}},"34":{"start":{"line":47,"column":8},"end":{"line":47,"column":53}},"35":{"start":{"line":48,"column":8},"end":{"line":48,"column":52}},"36":{"start":{"line":50,"column":8},"end":{"line":50,"column":28}},"37":{"start":{"line":53,"column":4},"end":{"line":53,"column":18}},"38":{"start":{"line":57,"column":2},"end":{"line":61,"column":4}},"39":{"start":{"line":58,"column":4},"end":{"line":60,"column":6}},"40":{"start":{"line":59,"column":6},"end":{"line":59,"column":25}},"41":{"start":{"line":63,"column":2},"end":{"line":67,"column":4}},"42":{"start":{"line":64,"column":4},"end":{"line":66,"column":6}},"43":{"start":{"line":65,"column":6},"end":{"line":65,"column":26}},"44":{"start":{"line":69,"column":2},"end":{"line":73,"column":4}}},"branchMap":{"1":{"line":3,"type":"if","locations":[{"start":{"line":3,"column":2},"end":{"line":3,"column":2}},{"start":{"line":3,"column":2},"end":{"line":3,"column":2}}]},"2":{"line":3,"type":"binary-expr","locations":[{"start":{"line":3,"column":6},"end":{"line":3,"column":34}},{"start":{"line":3,"column":38},"end":{"line":3,"column":48}}]},"3":{"line":5,"type":"if","locations":[{"start":{"line":5,"column":9},"end":{"line":5,"column":9}},{"start":{"line":5,"column":9},"end":{"line":5,"column":9}}]},"4":{"line":21,"type":"if","locations":[{"start":{"line":21,"column":4},"end":{"line":21,"column":4}},{"start":{"line":21,"column":4},"end":{"line":21,"column":4}}]},"5":{"line":27,"type":"if","locations":[{"start":{"line":27,"column":4},"end":{"line":27,"column":4}},{"start":{"line":27,"column":4},"end":{"line":27,"column":4}}]},"6":{"line":30,"type":"if","locations":[{"start":{"line":30,"column":4},"end":{"line":30,"column":4}},{"start":{"line":30,"column":4},"end":{"line":30,"column":4}}]},"7":{"line":41,"type":"if","locations":[{"start":{"line":41,"column":6},"end":{"line":41,"column":6}},{"start":{"line":41,"column":6},"end":{"line":41,"column":6}}]},"8":{"line":45,"type":"if","locations":[{"start":{"line":45,"column":13},"end":{"line":45,"column":13}},{"start":{"line":45,"column":13},"end":{"line":45,"column":13}}]}}}} | ||
{"/Users/will/Projects/email-scramble/email-scramble.js":{"path":"/Users/will/Projects/email-scramble/email-scramble.js","s":{"1":1,"2":1,"3":0,"4":1,"5":1,"6":0,"7":1,"8":46,"9":46,"10":46,"11":46,"12":46,"13":46,"14":46,"15":46,"16":0,"17":46,"18":0,"19":46,"20":46,"21":46,"22":46,"23":46,"24":46,"25":46,"26":3570,"27":3570,"28":360,"29":360,"30":360,"31":3210,"32":1100,"33":1100,"34":1100,"35":2110,"36":936,"37":936,"38":936,"39":1174,"40":46,"41":1,"42":16,"43":1},"b":{"1":[0,1],"2":[1,0],"3":[1,0],"4":[0,46],"5":[0,46],"6":[360,3210],"7":[1100,2110],"8":[936,1174]},"f":{"1":1,"2":1,"3":46,"4":16},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":26}}},"2":{"name":"(anonymous_2)","line":10,"loc":{"start":{"line":10,"column":8},"end":{"line":10,"column":24}}},"3":{"name":"rot","line":14,"loc":{"start":{"line":14,"column":12},"end":{"line":14,"column":47}}},"4":{"name":"rot18","line":57,"loc":{"start":{"line":57,"column":14},"end":{"line":57,"column":34}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":66,"column":4}},"2":{"start":{"line":3,"column":2},"end":{"line":9,"column":3}},"3":{"start":{"line":4,"column":4},"end":{"line":4,"column":44}},"4":{"start":{"line":5,"column":9},"end":{"line":9,"column":3}},"5":{"start":{"line":6,"column":4},"end":{"line":6,"column":35}},"6":{"start":{"line":8,"column":4},"end":{"line":8,"column":39}},"7":{"start":{"line":14,"column":2},"end":{"line":55,"column":4}},"8":{"start":{"line":15,"column":4},"end":{"line":15,"column":31}},"9":{"start":{"line":16,"column":4},"end":{"line":16,"column":49}},"10":{"start":{"line":17,"column":4},"end":{"line":17,"column":49}},"11":{"start":{"line":18,"column":4},"end":{"line":18,"column":30}},"12":{"start":{"line":19,"column":4},"end":{"line":19,"column":33}},"13":{"start":{"line":20,"column":4},"end":{"line":20,"column":33}},"14":{"start":{"line":22,"column":4},"end":{"line":22,"column":22}},"15":{"start":{"line":24,"column":4},"end":{"line":26,"column":5}},"16":{"start":{"line":25,"column":6},"end":{"line":25,"column":20}},"17":{"start":{"line":27,"column":4},"end":{"line":29,"column":5}},"18":{"start":{"line":28,"column":6},"end":{"line":28,"column":19}},"19":{"start":{"line":30,"column":4},"end":{"line":30,"column":28}},"20":{"start":{"line":31,"column":4},"end":{"line":31,"column":19}},"21":{"start":{"line":32,"column":4},"end":{"line":32,"column":20}},"22":{"start":{"line":33,"column":4},"end":{"line":33,"column":18}},"23":{"start":{"line":34,"column":4},"end":{"line":34,"column":24}},"24":{"start":{"line":35,"column":4},"end":{"line":35,"column":24}},"25":{"start":{"line":36,"column":4},"end":{"line":53,"column":5}},"26":{"start":{"line":37,"column":6},"end":{"line":37,"column":36}},"27":{"start":{"line":38,"column":6},"end":{"line":52,"column":7}},"28":{"start":{"line":39,"column":8},"end":{"line":39,"column":53}},"29":{"start":{"line":40,"column":8},"end":{"line":40,"column":58}},"30":{"start":{"line":41,"column":8},"end":{"line":41,"column":50}},"31":{"start":{"line":42,"column":13},"end":{"line":52,"column":7}},"32":{"start":{"line":43,"column":8},"end":{"line":43,"column":55}},"33":{"start":{"line":44,"column":8},"end":{"line":44,"column":59}},"34":{"start":{"line":45,"column":8},"end":{"line":45,"column":52}},"35":{"start":{"line":46,"column":13},"end":{"line":52,"column":7}},"36":{"start":{"line":47,"column":8},"end":{"line":47,"column":55}},"37":{"start":{"line":48,"column":8},"end":{"line":48,"column":59}},"38":{"start":{"line":49,"column":8},"end":{"line":49,"column":52}},"39":{"start":{"line":51,"column":8},"end":{"line":51,"column":28}},"40":{"start":{"line":54,"column":4},"end":{"line":54,"column":18}},"41":{"start":{"line":57,"column":2},"end":{"line":59,"column":4}},"42":{"start":{"line":58,"column":4},"end":{"line":58,"column":27}},"43":{"start":{"line":61,"column":2},"end":{"line":65,"column":4}}},"branchMap":{"1":{"line":3,"type":"if","locations":[{"start":{"line":3,"column":2},"end":{"line":3,"column":2}},{"start":{"line":3,"column":2},"end":{"line":3,"column":2}}]},"2":{"line":3,"type":"binary-expr","locations":[{"start":{"line":3,"column":6},"end":{"line":3,"column":34}},{"start":{"line":3,"column":38},"end":{"line":3,"column":48}}]},"3":{"line":5,"type":"if","locations":[{"start":{"line":5,"column":9},"end":{"line":5,"column":9}},{"start":{"line":5,"column":9},"end":{"line":5,"column":9}}]},"4":{"line":24,"type":"if","locations":[{"start":{"line":24,"column":4},"end":{"line":24,"column":4}},{"start":{"line":24,"column":4},"end":{"line":24,"column":4}}]},"5":{"line":27,"type":"if","locations":[{"start":{"line":27,"column":4},"end":{"line":27,"column":4}},{"start":{"line":27,"column":4},"end":{"line":27,"column":4}}]},"6":{"line":38,"type":"if","locations":[{"start":{"line":38,"column":6},"end":{"line":38,"column":6}},{"start":{"line":38,"column":6},"end":{"line":38,"column":6}}]},"7":{"line":42,"type":"if","locations":[{"start":{"line":42,"column":13},"end":{"line":42,"column":13}},{"start":{"line":42,"column":13},"end":{"line":42,"column":13}}]},"8":{"line":46,"type":"if","locations":[{"start":{"line":46,"column":13},"end":{"line":46,"column":13}},{"start":{"line":46,"column":13},"end":{"line":46,"column":13}}]}}}} |
@@ -13,21 +13,18 @@ (function (root, factory) { | ||
// https://github.com/mathiasbynens/rot | ||
var rot = function rot(str, n) { | ||
/* jshint ignore:start */ | ||
// Largely taken from https://github.com/mathiasbynens/rot. | ||
var rot = function rot(str, charRot, numRot) { | ||
var numbers = '0123456789'; | ||
var lowercase = 'abcdefghijklmnopqrstuvwxyz'; | ||
var uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; | ||
var regexNumber = /[0-9]/; | ||
var regexLowercase = /[a-z]/; | ||
var regexUppercase = /[A-Z]/; | ||
if (n == null) { | ||
// use ROT-13 by default | ||
n = 13; | ||
} | ||
n = Number(n); | ||
str = String(str); | ||
if (n == 0) { | ||
return str; | ||
if (charRot < 0) { | ||
charRot += 26; | ||
} | ||
if (n < 0) { // decode instead of encode | ||
n += 26; | ||
if (numRot < 0) { | ||
numRot += 10; | ||
} | ||
@@ -42,9 +39,13 @@ var length = str.length; // note: no need to account for astral symbols | ||
character = str.charAt(index); | ||
if (regexLowercase.test(character)) { | ||
if (regexNumber.test(character)) { | ||
currentPosition = numbers.indexOf(character); | ||
shiftedPosition = (currentPosition + numRot) % 10; | ||
result += numbers.charAt(shiftedPosition); | ||
} else if (regexLowercase.test(character)) { | ||
currentPosition = lowercase.indexOf(character); | ||
shiftedPosition = (currentPosition + n) % 26; | ||
shiftedPosition = (currentPosition + charRot) % 26; | ||
result += lowercase.charAt(shiftedPosition); | ||
} else if (regexUppercase.test(character)) { | ||
currentPosition = uppercase.indexOf(character); | ||
shiftedPosition = (currentPosition + n) % 26; | ||
shiftedPosition = (currentPosition + charRot) % 26; | ||
result += uppercase.charAt(shiftedPosition); | ||
@@ -56,22 +57,13 @@ } else { | ||
return result; | ||
/* jshint ignore:end */ | ||
}; | ||
var encoder = function encoder(n) { | ||
return function encode(str) { | ||
return rot(str, n); | ||
}; | ||
var rot18 = function rot18(str) { | ||
return rot(str, 13, 5); | ||
}; | ||
var decoder = function decoder(n) { | ||
return function decode(str) { | ||
return rot(str, -n); | ||
}; | ||
}; | ||
return { | ||
_rot: rot, | ||
encoder: encoder, | ||
decoder: decoder | ||
rot: rot, | ||
encode: rot18, | ||
decode: rot18 | ||
}; | ||
})); |
{ | ||
"name": "email-scramble", | ||
"version": "1.0.1", | ||
"description": "Scrambles email addresses to hide them from bots.", | ||
"version": "2.0.0", | ||
"description": "Scrambles email addresses and phone numbers with ROT-18 to hide them from bots", | ||
"main": "email-scramble.js", | ||
@@ -19,2 +19,6 @@ "scripts": { | ||
"address", | ||
"phone", | ||
"telephone", | ||
"cellphone", | ||
"tel", | ||
"scramble", | ||
@@ -28,3 +32,3 @@ "obfuscate", | ||
"rot", | ||
"rot13" | ||
"rot18" | ||
], | ||
@@ -31,0 +35,0 @@ "author": "ThibWeb", |
@@ -6,20 +6,20 @@ email-scramble | ||
Scrambles email addresses to hide them from bots. This library can be used server-side with Node/io.js or on the front-end. | ||
Scrambles email addresses and phone numbers with ROT-18 to hide them from bots. This library can be used server-side with Node/io.js or on the front-end (global variable, RequireJS, Browserify). | ||
Have a look at [the examples](https://rawgit.com/ThibWeb/email-scramble/master/examples/index.html). | ||
> Have a look at [the examples](https://rawgit.com/ThibWeb/email-scramble/master/examples/index.html). | ||
> If you'd like to know more about obfuscation techniques and their success ratio, [here's a great blog post on the subject](http://techblog.tilllate.com/2008/07/20/ten-methods-to-obfuscate-e-mail-addresses-compared/). | ||
If you'd like to know more about email obfuscation techniques and their success ratio, [here's a great blog post on the subject](http://techblog.tilllate.com/2008/07/20/ten-methods-to-obfuscate-e-mail-addresses-compared/). | ||
## Getting Started | ||
email-scramble uses a simple ROT transformation. The rotation amount can be any integer between 1 and 25. 0 and 26 won't produce any transformation, other numbers are useless (e.g. ROT-42 = ROT-16). | ||
email-scramble uses a simple ROT transformation. The default rotation is ROT-18, which means that letters will be rotated by 13 and numbers by 5. | ||
~~~javascript | ||
// To encode, first pick the ROT amount you want. | ||
var encode = emailScramble.encoder(16); | ||
var encodedEmail = encode('mail@example.com'); | ||
var encodedEmail = emailScramble.encode('mail@example.com'); | ||
var decodedMail = emailScramble.decode(encodedMail); | ||
// To decode, you should pick the same ROT amount. | ||
var decode = emailScramble.decoder(16); | ||
var decodedMail = decode(encodedMail); | ||
// You can also pick any other flavor of ROT: | ||
function myROT(str) { | ||
// Here letters are obfuscated with ROT-13 and numbers are kept clear. | ||
return emailScramble.rot(str, 13, 0); | ||
} | ||
~~~ | ||
@@ -30,13 +30,7 @@ | ||
~~~javascript | ||
(function (emailScramble) { | ||
'use strict'; | ||
var decode = emailScramble.decoder(5); | ||
// <a id="scrambled" href="rfnqyt:rfnq@jcfruqj.htr">rfnq@jcfruqj.htr</a> | ||
var link = document.getElementById('scrambled'); | ||
link.href = decode(link.href); | ||
link.innerHTML = decode(link.innerHTML); | ||
// <a id="scrambled" href="znvygb:znvy@rknzcyr.pbz">Send me an email!</a> | ||
var link = document.getElementById('scrambled'); | ||
link.href = emailScramble.decode(link.href); | ||
~~~ | ||
### Download & import | ||
@@ -43,0 +37,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73693
132
86