我希望有人能帮助一个非PHPP开发商,提供如何解密三重 DES URL Encodd 字符串(例如,在名为“q”的查询字符串变量中传给页面)的示例。
键是 24 位,内向矢量是 8 位。
C # 中的原始数据是:
- UTF-8 encoded as a byte array
- Encrypted with the key and IV
- Encoded as a Base 64 string
- URL encoded as a string
.
byte[] rawData;
TripleDES tripleDESalg = TripleDES.Create();
rawData = UTF8Encoding.UTF8.GetBytes(message);
ICryptoTransform cTransform = tripleDESalg.CreateEncryptor(key, IV);
byte[] resultArray = cTransform.TransformFinalBlock(rawData, 0, rawData.Length);
tripleDESalg.Clear();
encryptedText = Convert.ToBase64String(resultArray);
.
在PHP页面上,
- Decode the URL encoded string in the querystring variable "q"
- Decode the Base 64 encoded string (e.g. base64_decode)
- Decrypt the value using the same key and iv that was used to encrypt it (assume you control the encrypting and decrypting and both system know what the key and iv are)
- Print/echo the output