You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

27 lines
651 B

  1. // Copyright 2017 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package scrypt_test
  5. import (
  6. "encoding/base64"
  7. "fmt"
  8. "log"
  9. "golang.org/x/crypto/scrypt"
  10. )
  11. func Example() {
  12. // DO NOT use this salt value; generate your own random salt. 8 bytes is
  13. // a good length.
  14. salt := []byte{0xc8, 0x28, 0xf2, 0x58, 0xa7, 0x6a, 0xad, 0x7b}
  15. dk, err := scrypt.Key([]byte("some password"), salt, 1<<15, 8, 1, 32)
  16. if err != nil {
  17. log.Fatal(err)
  18. }
  19. fmt.Println(base64.StdEncoding.EncodeToString(dk))
  20. // Output: lGnMz8io0AUkfzn6Pls1qX20Vs7PGN6sbYQ2TQgY12M=
  21. }