Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dchest/pbkdf2
Go implementation of PBKDF2 key derivation function. (Modified original from https://bitbucket.org/taruti/pbkdf2.go) DEPRECATED. Please use the one from the official go.crypto repo: http://code.google.com/p/go/source/browse?repo=crypto#hg%2Fpbkdf2
https://github.com/dchest/pbkdf2
Last synced: about 1 month ago
JSON representation
Go implementation of PBKDF2 key derivation function. (Modified original from https://bitbucket.org/taruti/pbkdf2.go) DEPRECATED. Please use the one from the official go.crypto repo: http://code.google.com/p/go/source/browse?repo=crypto#hg%2Fpbkdf2
- Host: GitHub
- URL: https://github.com/dchest/pbkdf2
- Owner: dchest
- License: other
- Created: 2011-04-03T19:46:47.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-02-09T18:51:39.000Z (almost 13 years ago)
- Last Synced: 2024-06-20T17:30:34.103Z (5 months ago)
- Language: Go
- Homepage:
- Size: 97.7 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Package pbkdf2
==============Package pbkdf2 implements PBKDF2 key derivation function.
(Slightly modified version of https://bitbucket.org/taruti/pbkdf2.go,
with password helper functions removed)Functions
---------### func WithHMAC
func WithHMAC(hash func() hash.Hash, password []byte, salt []byte, iterations int, outlen int) []byte
WithHMAC derives key of length outlen from the provided password, salt,
and the number of iterations using PKCS#5 PBKDF2 with the provided
hash function in HMAC.Caller is responsible to make sure that outlen < (2^32-1) * hash.Size().
Example
-------package main
import (
"fmt"
"crypto/rand"
"crypto/sha256"
"github.com/dchest/pbkdf2"
)func main() {
password := "hello"
// Get random salt
salt := make([]byte, 32)
if _, err := rand.Reader.Read(salt); err != nil {
panic("random reader failed")
}
// Derive key
key := pbkdf2.WithHMAC(sha256.New, password, salt, 9999, 64)
fmt.Printf("%x", key)
}