MCPcopy
hub / github.com/Threekiii/Awesome-Redteam / aesEncrypt

Function aesEncrypt

scripts/ShellcodeWrapper/shellcode_encoder_py3.py:49–64  ·  view source on GitHub ↗

Encrypts data with the provided key. The returned byte array is as follow: :==============:==================================================: : IV (16bytes) : Encrypted (data + PKCS7 padding information) : :==============:==================================================:

(clearText, key)

Source from the content-addressed store, hash-verified

47
48#------------------------------------------------------------------------
49def aesEncrypt(clearText, key):
50 """Encrypts data with the provided key.
51 The returned byte array is as follow:
52 :==============:==================================================:
53 : IV (16bytes) : Encrypted (data + PKCS7 padding information) :
54 :==============:==================================================:
55 """
56
57 # Generate a crypto secure random Initialization Vector
58 iv = urandom(AES.block_size)
59
60 # Perform PKCS7 padding so that clearText is a multiple of the block size
61 clearText = pad(clearText)
62
63 cipher = AES.new(key, AES.MODE_CBC, iv)
64 return iv + cipher.encrypt(bytes(clearText))
65
66#======================================================================================================
67# OUTPUT FORMAT FUNCTIONS

Callers 1

Calls 1

padFunction · 0.85

Tested by

no test coverage detected