我对加密知之甚少,但我的目标是解密字符串。我得到了AES(128)的密钥。
然而,我必须从加密的字符串中取回IV, 这是前16位数。
此处为销售人员获取更多信息(如果我解释的不正确)的参考文件。
Encrypts the blob clearText using the specified algorithm and private key. Use this method when you want Salesforce to generate the initialization vector for you. It is stored as the first 128 bits (16 bytes) of the encrypted blob
为了取回IV, 我尝试过这样的东西(但我不认为这是正确的):
public string retrieveIv()
{
string iv = "";
string input = "bwZ6nKpBEsuAKM8lDTYH1Yl69KkHN1i3XehALbfgUqY=";
byte[] bytesToEncode = Encoding.UTF8.GetBytes(input);
for(int i = 0; i <= 15; i++){
iv += bytesToEncode[i].ToString(); ;
}
return iv;
}
(只要忽略输入是硬编码而不是参数化的这一事实;为测试目的更容易)
然后使用此 < a href=" https://stackoverflow.com/ questions/202011/ encrypt- decrypt- decrypt-string- in-net" 标题 = “ question” 问题 < question 解密字符串