Documentation ¶
Overview ¶
Package sm3 implements ShangMi(SM) sm3 hash algorithm.
Index ¶
Examples ¶
Constants ¶
View Source
const BlockSize int = 64
BlockSize the blocksize of SM3 in bytes.
View Source
const Size int = 32
Size the size of a SM3 checksum in bytes.
View Source
const SizeBitSize = 5
SizeBitSize the bit size of Size.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns a new hash.Hash computing the SM3 checksum. The Hash also implements encoding.BinaryMarshaler and encoding.BinaryUnmarshaler to marshal and unmarshal the internal state of the hash.
Example ¶
package main import ( "fmt" "github.com/emmansun/gmsm/sm3" ) func main() { h := sm3.New() h.Write([]byte("hello world\n")) fmt.Printf("%x", h.Sum(nil)) }
Output: 4cc2036b86431b5d2685a04d289dfe140a36baa854b01cb39fcd6009638e4e7a
Example (File) ¶
package main import ( "fmt" "io" "log" "os" "github.com/emmansun/gmsm/sm3" ) func main() { f, err := os.Open("file.txt") if err != nil { log.Fatal(err) } defer f.Close() h := sm3.New() if _, err := io.Copy(h, f); err != nil { log.Fatal(err) } fmt.Printf("%x", h.Sum(nil)) }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.