email2username
v1.0.0
Published
A bijective email to username converter with seeds for easy back and front-end development and also for respecting user privacy
Downloads
2
Maintainers
Readme
email2username
email2username is a bijective email to username with privacy seed. For easy back and front-end development but also for user privacy. this is work in progress
API
Email2Username(seed, length, baseDomains)
seed
is a chosen number to have a reproducible results (might be a secret)length
must be a natural number greater or equal to 3. We advice an even of length >= 4- When using
length
,baseDomains
must be a defined array of domains of type String - Without length,
username
would be very long and may not be user friendly.baseDomains
is optional in this case. This is fine and advised for mapping in backendEmail2Username#toUsername
takes an email and returns a usernameEmail2Username#toEmail
can theoretically recover the email iflength
has not been provided at first
Examples
This might be used on front-end as a substitute for real email
const { Email2Username } = require("email2username");
let lib = new Email2Username(3, 3, ['gmail.com', 'hotmail.com'])
lib.toUsername('[email protected]')
// 'bacloud14§231119'
lib.toEmail('bacloud14§231119')
// '[email protected]'
This might be used on back-end as a substitute for real email (maybe to communicate with other APIs or a matter of design? or maybe useless :S)
lib = new Email2Username(3)
lib.toUsername('[email protected]')
// 'bacloud14§231119221813252317'
lib.toEmail('bacloud14§231119221813252317')
// '[email protected]'
License
author
A.B. 2022
MIT