You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

28 lines
434 B

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
}