Skip to content

Instantly share code, notes, and snippets.

@muhaisen
Created March 13, 2021 10:28
Show Gist options
  • Save muhaisen/559a828d4d2d687623554e7cccdb19d7 to your computer and use it in GitHub Desktop.
Save muhaisen/559a828d4d2d687623554e7cccdb19d7 to your computer and use it in GitHub Desktop.
Tests decrypting Salesforce encryptWithManagedIV
public static void Decrypt()
{
using (AesManaged myAes = new AesManaged())
{
var protected_string = "W+YnphJ2T8pH4X+FNTwZvFPab+R4wRbZg/6HuyZ8Ese15LYp1UJLs7HvmIco4w6A";
byte[] protected_bytes = RetrieveCipher(protected_string);
// Encryption key
var encrption_key = Convert.FromBase64String(Constants.s_encrption_key);
// IV
var byte_IV = RetrieveIv(protected_string);
// Decrypt the bytes to a string.
string plan_text = DecryptStringFromBytes_Aes(protected_bytes, encrption_key, byte_IV);
// To User information object
UserInfo user_info = JsonConvert.DeserializeObject<UserInfo>(plan_text);
Console.WriteLine(user_info.MAIL);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment