Movatterモバイル変換


[0]ホーム

URL:


hmac

packagestandard library
go1.25.5Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License:BSD-3-ClauseImports:6Imported by:54,631

Details

Repository

cs.opensource.google/go/go

Links

Documentation

Overview

Package hmac implements the Keyed-Hash Message Authentication Code (HMAC) asdefined in U.S. Federal Information Processing Standards Publication 198.An HMAC is a cryptographic hash that uses a key to sign a message.The receiver verifies the hash by recomputing it using the same key.

Receivers should be careful to use Equal to compare MACs in order to avoidtiming side-channels:

// ValidMAC reports whether messageMAC is a valid HMAC tag for message.func ValidMAC(message, messageMAC, key []byte) bool {mac := hmac.New(sha256.New, key)mac.Write(message)expectedMAC := mac.Sum(nil)return hmac.Equal(messageMAC, expectedMAC)}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcEqualadded ingo1.1

func Equal(mac1, mac2 []byte)bool

Equal compares two MACs for equality without leaking timing information.

funcNew

func New(h func()hash.Hash, key []byte)hash.Hash

New returns a new HMAC hash using the givenhash.Hash type and key.New functions likecrypto/sha256.New can be used as h.h must return a new Hash every time it is called.Note that unlike other hash implementations in the standard library,the returned Hash does not implementencoding.BinaryMarshalerorencoding.BinaryUnmarshaler.

Types

This section is empty.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp