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 ¶
- func Encode(hash hash.Hash, msg, salt []byte) ([]byte, []byte, error)
- func Hash(hashNew func() hash.Hash, key, data []byte, tohex bool) []byte
- func MD5(key, data []byte, tohex bool) []byte
- func SHA1(key, data []byte, tohex bool) []byte
- func SHA256(key, data []byte, tohex bool) []byte
- func SHA512(key, data []byte, tohex bool) []byte
- func SaltEncode(hash hash.Hash, msg, fixed, rand []byte) []byte
- func Verify(hash hash.Hash, msg, salt, randSalt, pass []byte) bool
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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(nil, password, salt) if encrypt.Verify(nil, 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.