Created
January 14, 2023 06:29
-
-
Save ichtrojan/863aa7c5aca6760e1fb150c4b097284a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package helpers | |
import ( | |
"fmt" | |
"math" | |
"strings" | |
) | |
func HideEmail(email string) string { | |
em := strings.Split(email, "@") | |
name := strings.Join(em[0:len(em)-1], "@") | |
lenght := math.Floor(float64(len(name) / 2)) | |
return fmt.Sprintf("%s%s@%s", name[:int(lenght)], strings.Repeat("*", int(lenght)), em[len(em)-1]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment