Token has been stripped; Headers are encrypted

This commit is contained in:
Milos Gajdos
2019-11-25 18:56:00 +00:00
parent f82c267d81
commit 9095b99f6b
4 changed files with 65 additions and 52 deletions

View File

@@ -8,6 +8,14 @@ import (
"io"
)
// hash hahes the data into 32 bytes key and returns it
// hash uses sha256 underneath to hash the supplied key
func hash(key string) []byte {
hasher := sha256.New()
hasher.Write([]byte(key))
return hasher.Sum(nil)
}
// Encrypt encrypts data and returns the encrypted data
func Encrypt(data []byte, key string) ([]byte, error) {
// generate a new AES cipher using our 32 byte key
@@ -62,11 +70,3 @@ func Decrypt(data []byte, key string) ([]byte, error) {
return plaintext, nil
}
// hash hahes the data into 32 bytes key and returns it
// hash uses sha256 underneath to hash the supplied key
func hash(key string) []byte {
hasher := sha256.New()
hasher.Write([]byte(key))
return hasher.Sum(nil)
}