Skip to content

Small and simple package for anonymizing names, e-mails and domains

License

Notifications You must be signed in to change notification settings

emmanuelay/anonymize

Repository files navigation

anonymize Go Reference Codacy Badge Codacy Badge

Small and simple package for anonymizing names, e-mails and domains

Installation

go get -u github.com/emmanuelay/anonymize

Quick start

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

Using a custom rune

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

Contribute

Feel free to create a ticket if you see room for improvements or want to suggest something.

Contributors

About

Small and simple package for anonymizing names, e-mails and domains

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages