/// <summary> /// �����û��������룬����ʹ�õĽ����㷨����ɶ�ָ���ַ����Ľ��ܣ� /// <remarks>ָ���Ľ����㷨������ַ���ʹ�ü��ܵ��㷨һ�� /// �����㷨����������ͳ�ʼ��ƫ������Ҫ��һ�� /// DES��RC2:�������볤�Ⱥͳ�ʼ��ƫ�������� ������4���ַ�; /// Rijndael:�������볤�ȿ�����12,16���ַ�,��ʼ��ƫ����Ϊ8���ַ�; /// TripleDes:�������볤�ȿ���Ϊ8����12���ַ�,��ʼ��ƫ����Ϊ4���ַ�; /// </summary> /// <param name="plainText">������������</param> /// <param name="algorithm">ʹ�õļ����㷨</param> /// <param name="userInitialVector">����ʱʹ�õ���ʼƫ����</param> /// <param name="encryptionText">���ܺ���ַ���</param> /// <returns></returns> public static string Decrypt(string plainText, EncryptionAlgorithm algorithm, string userInitialVector, string encryptionText) { string result = string.Empty; SetKey(algorithm, plainText); SetInitialVector(algorithm, userInitialVector); EncryptTransform transform = new EncryptTransform(m_Key, m_initVec); byte[] bytesData = Convert.FromBase64String(encryptionText); byte[] bytes = null; try { bytes = transform.Decrypt(algorithm, bytesData); } catch (Exception exception) { throw exception; } if (bytes.Length > 0) { result = Encoding.Unicode.GetString(bytes); } m_Key = transform.Key; m_initVec = transform.InitVec; return result; }