0
相同的值與在線工具的頁面加密文本與三重DES:TripleDes的在C#中,不與工具
Key: 09F15B103BC56A6FA705E71F0850EE6D
IV: 0000000000000000
Text: 987654321FFFFFFFFFFFFFFFF
Encrypted value: 3AA4CCDEE3F753A3CE62B72252386873
在C#中,我有一個代碼,但我不能得到相同的值。
public static string Encrypt(string toEncrypt, string _key) {
TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
byte[] iv = { 0, 0, 0, 0, 0, 0, 0, 0 };
var CharHex = GetHexFromAscii(toEncrypt);
var input = ParseHex(CharHex);
tdes.IV = iv;
tdes.Mode = CipherMode.CBC;
tdes.Padding = PaddingMode.None;
ICryptoTransform cTransform = tdes.CreateEncryptor();
byte[] resultArray = cTransform.TransformFinalBlock(input, 0,
input.Length);
tdes.Clear();
var resTemp = Convert.ToBase64String(resultArray, 0, resultArray.Length);}}
有誰知道爲什麼?
與工具的頁面是 http://extranet.cryptomathic.com/descalc/index
該工具不會返回base64,而是原始的十六進制值。 – Gusman
如何獲得相同的價值? –
https://stackoverflow.com/questions/311165/how-do-you-convert-a-byte-array-to-a-hexadecimal-string-and-vice-versa – Gusman