# package sha1
`import "crypto/sha1"`
sha1包实现了SHA1哈希算法,参见[RFC 3174](http://tools.ietf.org/html/rfc3174)。
## Index
* [Constants](#pkg-constants)
* [func Sum(data []byte) [Size]byte](#Sum)
* [func New() hash.Hash](#New)
### Examples
* [New](#example-New)
* [Sum](#example-Sum)
## Constants
```
const BlockSize = 64
```
SHA1的块大小。
```
const Size = 20
```
SHA1校验和的字节数。
## func [Sum](https://github.com/golang/go/blob/master/src/crypto/sha1/sha1.go#L125 "View Source")
```
func Sum(data []byte) [Size]byte
```
返回数据data的SHA1校验和。
Example
```
data := []byte("This page intentionally left blank.")
fmt.Printf("% x", sha1.Sum(data))
```
Output:
```
af 06 49 23 bb f2 30 15 96 aa c4 c2 73 ba 32 17 8e bc 4a 96
```
## func [New](https://github.com/golang/go/blob/master/src/crypto/sha1/sha1.go#L51 "View Source")
```
func New() hash.Hash
```
返回一个新的使用SHA1校验的hash.Hash接口。
Example
```
h := sha1.New()
io.WriteString(h, "His money is twice tainted:")
io.WriteString(h, " 'taint yours and 'taint mine.")
fmt.Printf("% x", h.Sum(nil))
```
Output:
```
59 7f 6a 54 00 10 f9 4c 15 d7 18 06 a9 9a 2c 87 10 e7 47 bd
```
- 库
- package achive
- package tar
- package zip
- package bufio
- package builtin
- package bytes
- package compress
- package bzip2
- package flate
- package gzip
- package lzw
- package zlib
- package container
- package heap
- package list
- package ring
- package crypto
- package aes
- package cipher
- package des
- package dsa
- package ecdsa
- package elliptic
- package hmac
- package md5
- package rand
- package rc4
- package rsa
- package sha1
- package sha256
- package sha512
- package subtle
- package tls
- package x509
- package pkix
- package database
- package sql
- package driver
- package encoding
- package ascii85
- package asn1
- package base32
- package base64
- package binary
- package csv
- package gob
- package hex
- package json
- package pem
- package xml
- package errors
- package expvar
- package flag
- package fmt
- package go
- package doc
- package format
- package parser
- package printer
- package hash
- package adler32
- package crc32
- package crc64
- package fnv
- package html
- package template
- package image
- package color
- package palette
- package draw
- package gif
- package jpeg
- package png
- package index
- package suffixarray
- package io
- package ioutil
- package log
- package syslog
- package math
- package big
- package cmplx
- package rand
- package mime
- package multipart
- package net
- package http
- package cgi
- package cookiejar
- package fcgi
- package httptest
- package httputil
- package pprof
- package mail
- package rpc
- package jsonrpc
- package smtp
- package textproto
- package url
- package os
- package exec
- package signal
- package user
- package path
- package filepath
- package reflect
- package regexp
- package runtime
- package cgo
- package debug
- package pprof
- package race
- package sort
- package strconv
- package strings
- package sync
- package atomic
- package text
- package scanner
- package tabwriter
- package template
- package time
- package unicode
- package utf16
- package utf8
- package unsafe