Data="https://bbs.csdn.net/topics/ft+j7fuddoLtNSZ86TuO/eVkrhuCbhTUSeYiKwIh3nbM44HywhG2radHpfd8U4BEmiyyltT34W9on2oJxOBAx0nIVGEK/AV5vOsBuEaqAgv7d27oUYx/nL7rPfPOJa5WI6e3ceDlKtpiCjYrdmrGZQ4XXTkCZKEmOZJqPpH9nJdYPx16kF6Cx5+PPkE5BudUT0ID6GsRvzUIb/9NOmeeJmEo1dUgkj4GQ2Bgx8rVMtl+b3sIwiki2C/5jupPuTZMly29iF0qwy4/Hl83yJOcGT7zb98nZXf4Q3B6aZbBi1XJO6Gxq4hewOKU7rix0IwkWnE0dAleAx4zf3d5os19IZdzzhWEjpKZ4Pd2vWqR0fM="
Key="oGZLywjAdsoBzhqx54piAQ=="
'because there is no set iv, so the decryption is garbled
Response. Write (aes_des (data))
The Function aes_dec (STR)
Set the aes=CreateObject (" System. Security. Cryptography. RijndaelManaged ")
Set the utf8=CreateObject (" System. Text. UTF8Encoding "and)
Aes. The Mode=1 '1: CBC, 2: the ECB, 3: ofb, 4: CFB, 5: CTS
Aes. The Padding=2 '1: don't fill, 2: pkcs7, 3: zero, 4: ansix923, 5: ISO10126
Aes. The KeySize=128
Aes. BlockSize=128
Aes. Key=Base64ToByte (Key)
'aes. Key=???? 'here I don't know how to set the
The set dec=aes. CreateDecryptor ()
Byted=Base64ToByte (STR)
Byted=dec. TransformFinalBlock ((byted), 0, lenb (byted))
Byted=utf8. Get string ((byted))
Aes_dec=byted
End the Function
player can put the following c # initIV into asp code (VBS)?
Using System;
using System.Collections.Generic;
using System.Text;
Using System. Security. Cryptography.
Using System. IO;
The namespace Aop. Api. Util
{
The class AlipayEncrypt
{
///& lt; Summary>
///128 0 vector
///& lt;/summary>
Private static byte [] AES_IV=initIv (16);
///& lt; Summary>
///the initialization vector
///& lt;/summary>
///& lt; Param name="blockSize & gt;"
///& lt; Returns>
Private static byte [] initIv (int blockSize)
{
Byte []=new iv byte [blockSize];
For (int I=0; i{
Iv [I]=0 x0 (byte);
}
Return the iv;
}
///& lt; Summary>
///AES encryption
///& lt;/summary>
///& lt; Param name="the encryptKey & gt;"
///& lt; Param name="bizContent & gt;"
///& lt; Param name="charset" & gt;
///& lt; Returns>
Public static string AesEncrypt (string the encryptKey, string bizContent, string charset)
{
Byte [] keyArray.=the Convert FromBase64String (the encryptKey);
Byte [] toEncryptArray=null;
If (string. IsNullOrEmpty (charset))
{
ToEncryptArray=Encoding. UTF8. GetBytes (bizContent);
}
The else
{
ToEncryptArray=Encoding. GetEncoding (charset). GetBytes (bizContent);
}
System. Security. Cryptography. RijndaelManaged rDel=new System. Security. Cryptography. The RijndaelManaged ();
RDel. Key=keyArray;
RDel. Mode=System. Security. Cryptography. CipherMode. The CBC.
RDel. Padding=System. Security. Cryptography. PaddingMode. PKCS7;
RDel.=AES_IV IV;
System. Security. Cryptography. ICryptoTransform cTransform=rDel. CreateEncryptor rDel. Key, rDel. (IV);
Byte [] resultArray=cTransform. TransformFinalBlock (toEncryptArray, 0, toEncryptArray. Length);
Return the Convert. ToBase64String (resultArray);
}
///& lt; Summary>
///AES decryption
///& lt;/summary>
///& lt; Param name="the encryptKey & gt;"
///& lt; Param name="bizContent & gt;"
///& lt; Param name="charset" & gt;
///& lt; Returns>
Public static string AesDencrypt (string the encryptKey, string bizContent, string charset)
{
Byte [] keyArray.=the Convert FromBase64String (the encryptKey);
Byte [] toEncryptArray=the Convert. FromBase64String (bizContent);
System. Security. Cryptography. RijndaelManaged rDel=new System. Security. Cryptography. The RijndaelManaged ();
RDel. Key=keyArray;
RDel. Mode=System. Security. Cryptography. CipherMode. The CBC.
RDel. Padding=System. Security. Cryptography. PaddingMode. PKCS7;
RDel.=AES_IV IV;
System. Security. Cryptography. ICryptoTransform cTransform=rDel. CreateDecryptor (rDel. Key, rDel. IV);
Byte [] resultArray=cTransform. TransformFinalBlock (toEncryptArray, 0, toEncryptArray. Length);
If (string. IsNullOrEmpty (charset))
{
Return. Encoding UTF8. Get string (resultArray);
}
The else
{
Return Encoding. GetEncoding (charset). Get string (resultArray);
}
}
}
}
CodePudding user response:
Public AES_IV () As Byte=InitIv ()
The Function InitIv ()
ReDim AES_IV (0 To 15)
For I=0 To 15
AES_IV (I)=0
Next
Return AES_IV
End the Function
CodePudding user response: