MCPcopy Create free account
hub / github.com/TryGOTry/C2_Demo / AESDecrypt

Function AESDecrypt

C2_Client_Go/encode/encode.go:28–42  ·  view source on GitHub ↗
(encrypted []byte, key []byte)

Source from the content-addressed store, hash-verified

26}
27
28func AESDecrypt(encrypted []byte, key []byte) (decrypted []byte) {
29 cipher, _ := aes.NewCipher(generateKey(key))
30 decrypted = make([]byte, len(encrypted))
31 //
32 for bs, be := 0, cipher.BlockSize(); bs < len(encrypted); bs, be = bs+cipher.BlockSize(), be+cipher.BlockSize() {
33 cipher.Decrypt(decrypted[bs:be], encrypted[bs:be])
34 }
35
36 trim := 0
37 if len(decrypted) > 0 {
38 trim = len(decrypted) - int(decrypted[len(decrypted)-1])
39 }
40
41 return decrypted[:trim]
42}
43
44func generateKey(key []byte) (genKey []byte) {
45 genKey = make([]byte, 16)

Callers 1

DecodestrFunction · 0.70

Calls 1

generateKeyFunction · 0.70

Tested by

no test coverage detected