1.0.0 • Published 3 years ago
email2username v1.0.0
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)
seedis a chosen number to have a reproducible results (might be a secret)lengthmust be a natural number greater or equal to 3. We advice an even of length >= 4- When using
length,baseDomainsmust be a defined array of domains of type String - Without length,
usernamewould be very long and may not be user friendly.baseDomainsis optional in this case. This is fine and advised for mapping in backendEmail2Username#toUsernametakes an email and returns a usernameEmail2Username#toEmailcan theoretically recover the email iflengthhas 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('bacloud14@gmail.com')
// 'bacloud14§231119'
lib.toEmail('bacloud14§231119')
// 'bacloud14@gmail.com'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('bacloud14@gmail.com')
// 'bacloud14§231119221813252317'
lib.toEmail('bacloud14§231119221813252317')
// 'bacloud14@gmail.com'License
author
A.B. 2022
MIT
1.0.0
3 years ago