From db55bba1430939130be9aad3e4d54f901b0fac79 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sun, 6 Dec 2020 14:49:32 -0500 Subject: lib/aes: add AESEncryptECB --- lib/aes.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/aes.go') diff --git a/lib/aes.go b/lib/aes.go index e9b97d3..83bd028 100644 --- a/lib/aes.go +++ b/lib/aes.go @@ -19,6 +19,20 @@ func AESDecryptCBC(cipher, key, iv []byte) []byte { return output } +func AESEncryptECB(cipher, key []byte) []byte { + iter := len(cipher) / 16 + + // Encrypt 16 bytes at a time. + output := make([]byte, 0) + for i := 0; i < iter; i++ { + s := (i * 16) + e := (i * 16) + 16 + output = append(output, aesCipher(cipher[s:e], key)...) + } + + return output +} + func AESDecryptECB(cipher, key []byte) []byte { iter := len(cipher) / 16 -- cgit v1.2.3