-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathexample_stringkey_test.go
More file actions
66 lines (51 loc) · 1.05 KB
/
example_stringkey_test.go
File metadata and controls
66 lines (51 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package stringkey_test
import (
"fmt"
"github.com/tecnickcom/gogen/pkg/stringkey"
)
func ExampleNew() {
// input strings
args := []string{
"0123456789",
"abcdefghijklmnopqrstuvwxyz",
"Lorem ipsum dolor sit amet",
}
// generate a new key
sk := stringkey.New(args...)
fmt.Println(sk)
// Output:
// 2p8dmari397l8
}
func ExampleStringKey_Key() {
// generate a new key as uint64
k := stringkey.New(
"0123456789",
"abcdefghijklmnopqrstuvwxyz",
"Lorem ipsum dolor sit amet",
).Key()
fmt.Println(k)
// Output:
// 12797937727583693228
}
func ExampleStringKey_String() {
// generate a new key as 36-char encoded string
k := stringkey.New(
"0123456789",
"abcdefghijklmnopqrstuvwxyz",
"Lorem ipsum dolor sit amet",
).String()
fmt.Println(k)
// Output:
// 2p8dmari397l8
}
func ExampleStringKey_Hex() {
// generate a new key as fixed-length 16 digits hexadecimal string key.
k := stringkey.New(
"0123456789",
"abcdefghijklmnopqrstuvwxyz",
"Lorem ipsum dolor sit amet",
).Hex()
fmt.Println(k)
// Output:
// b19b688e8e3229ac
}