求C#短信加密算法!!!

来源:百度知道 编辑:UC知道 时间:2024/05/06 04:25:42
一定要是C#编的哈!谢谢!

using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;

namespace DataCrypto
{
///
/// 对称加密算法类
///
public class SymmetricMethod
{

private SymmetricAlgorithm mobjCryptoService;
private string Key;
///
/// 对称加密类的构造函数
///
public SymmetricMethod()
{
mobjCryptoService = new RijndaelManaged();
Key = "Guz(%&hj7x89H$yuBI0456FtmaT5&fvHUFCy76*h%(HilJ$lhj!y6&(*jkP87jH7";
}
///
/// 获得密钥
///
/// 密钥
private byte[] GetLegalKey()
{
string sTemp = Key;
mobjCryptoService.GenerateKey();
byte[] bytTemp = mobjCryptoService.Key;
int KeyLength = bytTemp.Length;
if (sTemp.Length > KeyLength)
sTemp = sTemp.Substring(0, KeyLength);
else if (sTemp.Length < KeyLength)
sTemp = sTemp.PadRight(KeyLength, ' ');
return ASCIIEncoding.ASCII.GetBytes(sTemp);
}
/// <