哪位高手看看下面这个是什么解密算法,
怎么根据它写成一个加密的?
字符串为
ghFwNo9yfC4rLwtfiSth9+lIjUTXx8B78F7ehIKo1ohPdssjjLJnF0MWP0CH/qVpSvIdbDYkzxBuh9UwTeZjBmF4fqmjb0g8AmViKoXwBJRgPdPyN8FfN8CIdq1Z/SGospdja+8uG00Ml30b1X0S8GeW9+/cqt5XigSGj2nME7uaFj6iMDcUfIrzcCp59KKueSQfLug5iElxnF9hTs2QCg==以下算法可以将它解密出来
Data Source=192.168.1.15;Initial Catalog=AYLData;User ID=sa;Password=water345 哪位高手能根据这个算法,写出一个将上面解密过的Data Source=192.168.1.15;Initial Catalog=AYLData;User ID=sa;Password=water345
加密成
ghFwNo9yfC4rLwtfiSth9+lIjUTXx8B78F7ehIKo1ohPdssjjLJnF0MWP0CH/qVpSvIdbDYkzxBuh9UwTeZjBmF4fqmjb0g8AmViKoXwBJRgPdPyN8FfN8CIdq1Z/SGospdja+8uG00Ml30b1X0S8GeW9+/cqt5XigSGj2nME7uaFj6iMDcUfIrzcCp59KKueSQfLug5iElxnF9hTs2QCg==namespace AJXCommon
{
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text; public class AJXDES
{
public static string DESDecrypt(string encryptedValue)
{
string key = "ajiaxisc";
return DESDecrypt(encryptedValue, key, key);
} public static string DESDecrypt(string encryptedValue, string key)
{
return DESDecrypt(encryptedValue, key, key);
} public static string DESDecrypt(string encryptedValue, string key, string IV)
{
key = key + "asdfghjk";
IV = IV + "asdfghjk";
key = key.Substring(0, 8);
IV = IV.Substring(0, 8);
SymmetricAlgorithm sa = new DESCryptoServiceProvider();
sa.Key = Encoding.UTF8.GetBytes(key);
sa.IV = Encoding.UTF8.GetBytes(IV);
ICryptoTransform ct = sa.CreateDecryptor();
byte[] byt = Convert.FromBase64String(encryptedValue);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, ct, CryptoStreamMode.Write);
cs.Write(byt, 0, byt.Length);
cs.FlushFinalBlock();
cs.Close();
return Encoding.Unicode.GetString(ms.ToArray());
}
}
}
怎么根据它写成一个加密的?
字符串为
ghFwNo9yfC4rLwtfiSth9+lIjUTXx8B78F7ehIKo1ohPdssjjLJnF0MWP0CH/qVpSvIdbDYkzxBuh9UwTeZjBmF4fqmjb0g8AmViKoXwBJRgPdPyN8FfN8CIdq1Z/SGospdja+8uG00Ml30b1X0S8GeW9+/cqt5XigSGj2nME7uaFj6iMDcUfIrzcCp59KKueSQfLug5iElxnF9hTs2QCg==以下算法可以将它解密出来
Data Source=192.168.1.15;Initial Catalog=AYLData;User ID=sa;Password=water345 哪位高手能根据这个算法,写出一个将上面解密过的Data Source=192.168.1.15;Initial Catalog=AYLData;User ID=sa;Password=water345
加密成
ghFwNo9yfC4rLwtfiSth9+lIjUTXx8B78F7ehIKo1ohPdssjjLJnF0MWP0CH/qVpSvIdbDYkzxBuh9UwTeZjBmF4fqmjb0g8AmViKoXwBJRgPdPyN8FfN8CIdq1Z/SGospdja+8uG00Ml30b1X0S8GeW9+/cqt5XigSGj2nME7uaFj6iMDcUfIrzcCp59KKueSQfLug5iElxnF9hTs2QCg==namespace AJXCommon
{
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text; public class AJXDES
{
public static string DESDecrypt(string encryptedValue)
{
string key = "ajiaxisc";
return DESDecrypt(encryptedValue, key, key);
} public static string DESDecrypt(string encryptedValue, string key)
{
return DESDecrypt(encryptedValue, key, key);
} public static string DESDecrypt(string encryptedValue, string key, string IV)
{
key = key + "asdfghjk";
IV = IV + "asdfghjk";
key = key.Substring(0, 8);
IV = IV.Substring(0, 8);
SymmetricAlgorithm sa = new DESCryptoServiceProvider();
sa.Key = Encoding.UTF8.GetBytes(key);
sa.IV = Encoding.UTF8.GetBytes(IV);
ICryptoTransform ct = sa.CreateDecryptor();
byte[] byt = Convert.FromBase64String(encryptedValue);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, ct, CryptoStreamMode.Write);
cs.Write(byt, 0, byt.Length);
cs.FlushFinalBlock();
cs.Close();
return Encoding.Unicode.GetString(ms.ToArray());
}
}
}
sa.CreateEncryptor()就是加密了