Small and simple package for anonymizing names, e-mails and domains
go get -u github.com/emmanuelay/anonymize
package main
import (
"fmt"
"github.com/emmanuelay/anonymize"
)
func main() {
name := "John Doe"
anonymousName := anonymize.Name(name)
fmt.Println(name, ":", anonymousName)
email := "john.doe@gmail.com"
anonymousEmail := anonymize.Email(email)
fmt.Println(email, ":", anonymousEmail)
domain := "www.john-doe.com"
anonymousDomain := anonymize.Domain(domain)
fmt.Println(domain, ":", anonymousDomain)
}
..this will result in the following output:
John Doe : J*** D**
john.doe@gmail.com : j***.d**@g****.com
www.john-doe.com : www.j***-d**.com
If you want to change the anonymization character/rune, there are methods that allow this:
package main
import (
"fmt"
"github.com/emmanuelay/anonymize"
)
func main() {
name := "John Doe"
anonymousName := anonymize.NameWithCustomRune(name, '•')
fmt.Println(name, ":", anonymousName)
email := "john.doe@gmail.com"
anonymousEmail := anonymize.EmailWithCustomRune(email, 'x')
fmt.Println(email, ":", anonymousEmail)
domain := "www.john-doe.com"
anonymousDomain := anonymize.DomainWithCustomRune(domain, '⚪')
fmt.Println(domain, ":", anonymousDomain)
}
..this will result in the following output:
John Doe : J••• D••
john.doe@gmail.com : jxxx.dxx@gxxxx.com
www.john-doe.com : www.j⚪⚪⚪-d⚪⚪.com
Feel free to create a ticket if you see room for improvements or want to suggest something.