dotifier
v1.2.0
Published
Encode an integer into a Gmail address using dots
Downloads
7
Maintainers
Readme
dotifier 

Encode an integer into a Gmail address using dots
Install
$ npm install --save dotifierUsage
Server
var dotifier = require('dotifier');Client
Dotifier can be loaded either directly, or using AMD.
Note: requires validator.js
<script type="application/javascript" src="dotifier.js"></script>Example usage:
console.log(dotifier.encode('[email protected]', 1));
//=> '[email protected]'
console.log(dotifier.encode('[email protected]', 9));
//=> '[email protected]'
console.log(dotifier.encode('[email protected]', 1337));
//=> '[email protected]'
console.log(dotifier.decode('[email protected]'));
//=> 1
console.log(dotifier.decode('[email protected]'));
//=> 9
console.log(dotifier.decode('[email protected]'));
//=> 1337How it works
Gmail doesn't recognize dots as characters within usernames, meaning you can add or remove dots from a Gmail address without changing the actual destination address:
[email protected] = [email protected]
[email protected] = [email protected]
[email protected] = [email protected]All these addresses belong to the same person. You can test this yourself if you try to sign in with your username with a dot removed or added to it. You'll still sign in to your account. Source
By treating a dot as a 1 and the absence of a dot as a 0, we can store an arbitrary binary number in a Gmail address and later retrieve it:
0 = 0b0 = [email protected]
1 = 0b1 = [email protected]
2 = 0b10 = [email protected]
3 = 0b11 = [email protected]
10 = 0b1010 = [email protected]
43 = 0b101011 = [email protected]API
encode(email, integer)
Returns a string, or null if the input is invalid.
Required
Type: string
Gmail address to use.
integer
Required
Type: number
Integer to encode.
decode(email)
Returns an integer, or null if the input is invalid.
Required
Type: string
Gmail address to decode.
License
MIT © Soullesswaffle
