Documentation
¶
Overview ¶
Package md5 は、RFC 1321で定義されたMD5ハッシュアルゴリズムを実装します。
MD5は暗号学的に破られており、安全なアプリケーションには使用されるべきではありません。
Index ¶
Examples ¶
Constants ¶
View Source
const BlockSize = 64
MD5のブロックサイズ(バイト単位)。
View Source
const Size = 16
MD5チェックサムのバイト数。
Variables ¶
This section is empty.
Functions ¶
func New ¶
NewはMD5チェックサムを計算する新しい hash.Hash を返します。ハッシュは 最内部の状態をマーシャリングおよびアンマーシャリングするために encoding.BinaryMarshaler と encoding.BinaryUnmarshaler も実装しています。
Example ¶
package main
import (
"github.com/shogo82148/std/crypto/md5"
"github.com/shogo82148/std/fmt"
"github.com/shogo82148/std/io"
)
func main() {
h := md5.New()
io.WriteString(h, "The fog is getting thicker!")
io.WriteString(h, "And Leon's getting laaarger!")
fmt.Printf("%x", h.Sum(nil))
}
Output: e2c569be17396eca2a2e3c11578123ed
Example (File) ¶
package main
import (
"github.com/shogo82148/std/crypto/md5"
"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 := md5.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 はデータのMD5ハッシュ値を返します。
Example ¶
package main
import (
"github.com/shogo82148/std/crypto/md5"
"github.com/shogo82148/std/fmt"
)
func main() {
data := []byte("These pretzels are making me thirsty.")
fmt.Printf("%x", md5.Sum(data))
}
Output: b0804ec967f48520697662a204f5fe72
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.