Documentation ΒΆ
Overview ΒΆ
Package bytesmap can be used to encode strings into emojis. Can be useful to "humanize" hard to remember/recognize texts such as Hashes, keys, other encodes like base64, ip's and so on.
Depending on the text the result may have fewer characters, but definately will have more bytes in length, so is not an efficient compresison method, is just an encoding like base64, but way cooler and friendlier.
The algorithm is very simple: it split the string in a series of bytes, and map each byte by its value to an unique emoji. A byte can have only 255 possible values, so we only need 255 different emojis to encode ... anything.
Index ΒΆ
Examples ΒΆ
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func DecodeString ΒΆ
DecodeString overload the Decode() function.
Example ΒΆ
beauty := []string{ "πππππππππ", //127.0.0.1 "ππππΎππ¬πͺβ", //base64 for "emoji" "πππππππ’πππππππ€ππ€πππππππππππ€πππππππ’π’πππ€ππ", //sha1 for "password" } for _, s := range beauty { original, err := DecodeString(s) if err != nil { log.Panic(err) } fmt.Printf("%s => %s\n", s, original) }
Output: πππππππππ => 127.0.0.1 ππππΎππ¬πͺβ => ZW1vamk= πππππππ’πππππππ€ππ€πππππππππππ€πππππππ’π’πππ€ππ => 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8
func Encode ΒΆ
Encode a stream of bytes (we presume it is a string) into an emoji form. Each possible byte value (0-255) is mapped to an unique emoji.
func EncodeString ΒΆ
EncodeString is an overload of Encode(), most of the cases you'll need this to avoid code duplication ([]byte <-> string).
Example ΒΆ
ugly := []string{ "127.0.0.1", "ZW1vamk=", //base64 for "emoji" "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8", //sha1 for "password" } for _, s := range ugly { emojified, err := EncodeString(s) if err != nil { log.Panic(err) } fmt.Printf("%s => %s\n", s, emojified) }
Output: 127.0.0.1 => πππππππππ ZW1vamk= => ππππΎππ¬πͺβ 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8 => πππππππ’πππππππ€ππ€πππππππππππ€πππππππ’π’πππ€ππ
Types ΒΆ
This section is empty.