OSDN Git Service

Merge pull request #201 from Bytom/v0.1
[bytom/vapor.git] / vendor / github.com / bytom / crypto / scrypt / example_test.go
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
5 package scrypt_test
6
7 import (
8         "encoding/base64"
9         "fmt"
10         "log"
11
12         "golang.org/x/crypto/scrypt"
13 )
14
15 func Example() {
16         // DO NOT use this salt value; generate your own random salt. 8 bytes is
17         // a good length.
18         salt := []byte{0xc8, 0x28, 0xf2, 0x58, 0xa7, 0x6a, 0xad, 0x7b}
19
20         dk, err := scrypt.Key([]byte("some password"), salt, 1<<15, 8, 1, 32)
21         if err != nil {
22                 log.Fatal(err)
23         }
24         fmt.Println(base64.StdEncoding.EncodeToString(dk))
25         // Output: lGnMz8io0AUkfzn6Pls1qX20Vs7PGN6sbYQ2TQgY12M=
26 }