xamust / go-masker

Simple utility of creating a mask for sensitive information

Home Page:https://godoc.org/github.com/ggwhite/go-masker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Golang Masker (forked by @xamust)

Add custom masker

masker := New()
	out := func(i string) string {
		l := len([]rune(i))
		if l == 0 {
			return ""
		}
// set start index and length
		return masker.fixedOverlay(i, 5, 16)
	}
masker.OTMaskerString("AA11111BB1111111111111111CC", out)
---------
AA111*****************111CC
	out1 := func(i string) string {
		l := len([]rune(i))
		if l == 0 {
			return ""
		}
// set start index and length
		return masker.fixedOverlay(i, 5, 16)
	}
 // add to sync.Map func and key
	masker.AddCustomMasker("customKey1", out1)

	out2 := func(i string) string {
		l := len([]rune(i))
		if l == 0 {
			return ""
		}
// set start index and length
		return masker.fixedOverlay(i, 2, 3)
	}
// add to sync.Map func and key
	masker.AddCustomMasker("customKey2", out2)

masker.MaskerString("customKey1", "AA11111BB1111111111111111CC")
masker.MaskerString("customKey2", "A111AA11")
---------
AA111*****************111CC
A1****11

About

Simple utility of creating a mask for sensitive information

https://godoc.org/github.com/ggwhite/go-masker


Languages

Language:Go 100.0%