主题:救命啊!!!
大家好!!
是一个关于加密的算法,我在VC++6.0中编译始终出现4个错误,而且原程序我也看不懂,请所有的高手帮帮看看问题出现在什么地方,怎么解决??谢谢!!
原程序:
/// 密钥字符串:27jrWz2sxrVbR+pnyg6jWHhgNk4sZo46
/// 要加密的字符串:3033$13311083060$D10$2004-02-24 16:19:27
/// 加密后的字符串:KoewfwcFjuBwlzVOh5UOU3FU/8weXQd9B1RoLeVS3UCp9aVfQuivfSTrJofn/7d9 [STAThread]
static void main(string[] args)
{
string key = "27jrWz2sxrVbR+pnyg6jWHhgNk4sZo46"; //密钥字符串
byte[] keybytes = Convert.FromBase64String(key);
string src = "3033$13311083060$D10$2004-02-24 16:19:27";
byte[] srcbyte = Encoding.ASCII.GetBytes(src);
TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
tdes.Mode = CipherMode.ECB;
tdes.Key = keybytes;
tdes.Padding = PaddingMode.PKCS7;
MemoryStream fout = new System.IO.MemoryStream(80);
MemoryStream fin = new System.IO.MemoryStream(80);
CryptoStream encStream = new CryptoStream(fout, tdes.CreateEncryptor(), CryptoStreamMode.Write);
encStream.Write(srcbyte,0,srcbyte.Length);
encStream.FlushFinalBlock();
CryptoStream deStream = new CryptoStream(fin,tdes.CreateDecryptor(),CryptoStreamMode.Write);
deStream.Write(fout.ToArray(),0,(int)(fout.Length));
Console.WriteLine(Encoding.ASCII.GetString((fin.ToArray())));
string outputString = Convert.ToBase64String(fout.ToArray());
Console.WriteLine(outputString);
Console.ReadLine();
}
编译的错误:
1.cpp(20) : error C2065: 'string' : undeclared identifier
1.cpp(20) : error C2059: syntax error : ']'
1.cpp(21) : error C2143: syntax error : missing ';' before '{'
1.cpp(21) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.