Documentation ¶
Overview ¶
Package encrypt implements a encrypt tool with fix salt and random salt.
Algorithm:
Give message and fix salt, return Hash(msg, Hash(salt + randSalt)) as result.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Hash = sha256.New
Hash is the hash function used for Encode and SaltEncode
View Source
var SaltSize = sha256.Size
SaltSize is the size of generated salt in bytes used in Encode
Functions ¶
func SaltEncode ¶
SaltEncode encode the message with a fixed salt and a random salt, typically used to verify
Example ¶
package main import ( "fmt" "github.com/cosiner/gohper/crypto/encrypt" ) func main() { password := []byte("abcdefg") salt := []byte("123456") enc, randSalt, _ := encrypt.Encode(password, salt) if encrypt.Verify(password, salt, randSalt, enc) { fmt.Println("Password Match") } else { fmt.Println("Password don't match") } }
Output: Password Match
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.