example_test.go 491 B

12345678910111213141516171819202122
  1. package scrypt_test
  2. import (
  3. "encoding/base64"
  4. "fmt"
  5. "log"
  6. "golang.org/x/crypto/scrypt"
  7. )
  8. func Example() {
  9. // DO NOT use this salt value; generate your own random salt. 8 bytes is
  10. // a good length.
  11. salt := []byte{0xc8, 0x28, 0xf2, 0x58, 0xa7, 0x6a, 0xad, 0x7b}
  12. dk, err := scrypt.Key([]byte("some password"), salt, 1<<15, 8, 1, 32)
  13. if err != nil {
  14. log.Fatal(err)
  15. }
  16. fmt.Println(base64.StdEncoding.EncodeToString(dk))
  17. // Output: lGnMz8io0AUkfzn6Pls1qX20Vs7PGN6sbYQ2TQgY12M=
  18. }