March 2019
Intermediate to advanced
336 pages
9h 9m
English
Hash functions are used in cryptography and other areas. These data structures are presented with code examples related to cryptography. There are two ways to implement a hash function in Go: with crc32 or sha256. Marshaling (changing the string to an encoded form) saves the internal state, which is used for other purposes later. A BinaryMarshaler (converting the string into binary form) example is explained in this section:
//main package has examples shown// in Hands-On Data Structures and algorithms with Go bookpackage main// importing bytes, crpto/sha256, encoding, fmt and log packageimport ( "bytes" "crypto/sha256" "encoding" "fmt" "log" "hash")
The main method creates a binary marshaled hash of two example strings. ...
Read now
Unlock full access