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

  1. package Encryption
  2. import (
  3. "crypto/aes"
  4. "crypto/cipher"
  5. "crypto/hmac"
  6. "crypto/sha256"
  7. "hash"
  8. )
  9. func CreateHash(key string) []byte {
  10. var h hash.Hash
  11. h = hmac.New(sha256.New, []byte(key))
  12. h.Write([]byte(key))
  13. return h.Sum(nil)
  14. }
  15. func CreateKey(hashedKey []byte) (cipher.Block, error) {
  16. var (
  17. block cipher.Block
  18. e error
  19. )
  20. block, e = aes.NewCipher(hashedKey)
  21. if e != nil {
  22. return nil, e
  23. }
  24. return block, nil
  25. }