package Encryption
|
|
|
|
import (
|
|
"crypto/aes"
|
|
"crypto/cipher"
|
|
"crypto/hmac"
|
|
"crypto/sha256"
|
|
"hash"
|
|
)
|
|
|
|
func CreateHash(key string) []byte {
|
|
var h hash.Hash
|
|
h = hmac.New(sha256.New, []byte(key))
|
|
h.Write([]byte(key))
|
|
return h.Sum(nil)
|
|
}
|
|
|
|
func CreateKey(hashedKey []byte) (cipher.Block, error) {
|
|
var (
|
|
block cipher.Block
|
|
e error
|
|
)
|
|
block, e = aes.NewCipher(hashedKey)
|
|
if e != nil {
|
|
return nil, e
|
|
}
|
|
return block, nil
|
|
}
|