PadKey formats the key to the correct padding (32 byte)
(key []byte)
| 11 | |
| 12 | // PadKey formats the key to the correct padding (32 byte) |
| 13 | func PadKey(key []byte) []byte { |
| 14 | if len(key) == 32 { |
| 15 | return key |
| 16 | } else if len(key) > 32 { |
| 17 | return key[:32] |
| 18 | } |
| 19 | |
| 20 | // Append to key this wont change the key |
| 21 | for len(key) < 32 { |
| 22 | key = append(key, ' ') |
| 23 | } |
| 24 | |
| 25 | return key |
| 26 | } |
| 27 | |
| 28 | // EncryptAES encrypts the given data with the given key |
| 29 | func EncryptAES(key, data []byte) ([]byte, error) { |
no outgoing calls