Constants

  1. const BlockSize = 64
  2. const Size = 20

func Sum(data []byte) [Size]byte 返回数据data的SHA1校验和

  1. data := []byte("This page intentionally left blank.")
  2. fmt.Printf("%x", sha1.Sum(data))
  3. af064923bbf2301596aac4c273ba32178ebc4a96

func New() hash.Hash 返回一个新的使用SHA1校验的hash.Hash接口

  1. h := sha1.New()
  2. io.WriteString(h, "His money is twice tainted:")
  3. io.WriteString(h, " 'taint yours and 'taint mine.")
  4. fmt.Printf("% x", h.Sum(nil))
  5. 59 7f 6a 54 00 10 f9 4c 15 d7 18 06 a9 9a 2c 87 10 e7 47 bd