Skip to content

Instantly share code, notes, and snippets.

@glides
Last active February 4, 2020 09:25
Show Gist options
  • Save glides/82fa71ceb12c0e7b26941624d40260b0 to your computer and use it in GitHub Desktop.
Save glides/82fa71ceb12c0e7b26941624d40260b0 to your computer and use it in GitHub Desktop.
Decrypt AES-256 in Boo
# AES-256 with key decryption function Boo Lang
public static def decrypt(ciphertext as (byte), key as string) as (byte):
using aesAlg = Aes.Create():
salt = array(byte,[0x12,0x35,0x56,0x78,0x90,0xAB,0xAD,0xEF,0xDD,0x31])
rfc = Rfc2898DeriveBytes(key,salt)
aesAlg.Padding = PaddingMode.PKCS7
aesAlg.KeySize = 256
aesAlg.Key = rfc.GetBytes(32)
aesAlg.IV = rfc.GetBytes(16)
decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV)
using decryptedData = MemoryStream():
using cryptoStream = CryptoStream(decryptedData, decryptor, CryptoStreamMode.Write):
cryptoStream.Write(ciphertext, 0, ciphertext.Length)
cryptoStream.FlushFinalBlock()
return decryptedData.ToArray()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment