Created
March 13, 2021 10:28
-
-
Save muhaisen/559a828d4d2d687623554e7cccdb19d7 to your computer and use it in GitHub Desktop.
Tests decrypting Salesforce encryptWithManagedIV
This file contains 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 characters
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