Last active
February 4, 2020 09:25
-
-
Save glides/3eec98625a6f88c9894ec56a9b2cf900 to your computer and use it in GitHub Desktop.
Revisions
-
glides revised this gist
Feb 4, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # AES-256 with key encryption function Boo Lang public static def encrypt(cleartext as (byte), key as string) as (byte): using aesAlg = Aes.Create(): salt = array(byte,[0x12,0x35,0x56,0x78,0x90,0xAB,0xAD,0xEF,0xDD,0x31]) -
glides created this gist
Feb 4, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ public static def encrypt(cleartext 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) encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV) using encryptedData = MemoryStream(): using cryptoStream = CryptoStream(encryptedData, encryptor, CryptoStreamMode.Write): cryptoStream.Write(cleartext, 0, cleartext.Length) cryptoStream.FlushFinalBlock() return encryptedData.ToArray()