Documentation
¶
Overview ¶
パッケージsha1は、RFC 3174で定義されているSHA-1ハッシュアルゴリズムを実装しています。
SHA-1は暗号学的に破られており、セキュアなアプリケーションには使用すべきではありません。
Index ¶
Examples ¶
Constants ¶
View Source
const BlockSize = 64
SHA-1のブロックサイズ(バイト単位)です。
View Source
const Size = 20
SHA-1チェックサムのサイズ(バイト単位)。
Variables ¶
This section is empty.
Functions ¶
func New ¶
NewはSHA1チェックサムを計算する新しいhash.Hashを返します。Hashはまた、encoding.BinaryMarshalerとencoding.BinaryUnmarshalerを実装しており、ハッシュの内部状態をマーシャリングおよびアンマーシャリングすることができます。
Example ¶
package main import ( "github.com/shogo82148/std/crypto/sha1" "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/io" ) func main() { 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
Example (File) ¶
package main import ( "github.com/shogo82148/std/crypto/sha1" "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/io" "github.com/shogo82148/std/log" "github.com/shogo82148/std/os" ) func main() { f, err := os.Open("file.txt") if err != nil { log.Fatal(err) } defer f.Close() h := sha1.New() if _, err := io.Copy(h, f); err != nil { log.Fatal(err) } fmt.Printf("% x", h.Sum(nil)) }
Output:
func Sum ¶ added in v1.2.0
SumはデータのSHA-1チェックサムを返します。
Example ¶
package main import ( "github.com/shogo82148/std/crypto/sha1" "github.com/shogo82148/std/fmt" ) func main() { 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
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.