110,538
社区成员
发帖
与我相关
我的任务
分享
public virtual byte[] EncryptPassword(byte[] password)
{
Type machineKeySection = typeof(MachineKeySection);
Type[] paramTypes = new Type[] { typeof(bool), typeof(byte[]), typeof(byte[]), typeof(int), typeof(int) };
MethodInfo encryptOrDecryptData = machineKeySection.GetMethod("EncryptOrDecryptData", BindingFlags.Static | BindingFlags.NonPublic, null, paramTypes, null);
return (byte[])encryptOrDecryptData.Invoke(null, new object[] { true, password, null, 0, password.Length });
}
public string EncodePassword(string pass, string salt)
{
byte[] bIn = Encoding.Unicode.GetBytes(pass);
byte[] bSalt = Convert.FromBase64String(salt);
byte[] bAll = new byte[bSalt.Length + bIn.Length];
byte[] bRet = null;
Buffer.BlockCopy(bSalt, 0, bAll, 0, bSalt.Length);
Buffer.BlockCopy(bIn, 0, bAll, bSalt.Length, bIn.Length);
bRet = EncryptPassword(bAll);
return Convert.ToBase64String(bRet);
}
using System.Web.Configuration;
using System.Reflection;
private void button1_Click(object sender, EventArgs e)
{
//User user=Users.GetUser("10000");
MessageBox.Show(EncodePassword("51aspx.com", "Ehk/gwOk7mpqna7M/8hc5g=="));
}
public string EncodePassword(string pass, string salt)
{
byte[] bIn = Encoding.Unicode.GetBytes(pass);
byte[] bSalt = Convert.FromBase64String(salt);
byte[] bAll = new byte[bSalt.Length + bIn.Length];
byte[] bRet = null;
Buffer.BlockCopy(bSalt, 0, bAll, 0, bSalt.Length);
Buffer.BlockCopy(bIn, 0, bAll, bSalt.Length, bIn.Length);
bRet = EncryptPassword(bAll);
return Convert.ToBase64String(bRet);
}
public virtual byte[] EncryptPassword(byte[] password)
{
Type machineKeySection = typeof(MachineKeySection);
Type[] paramTypes = new Type[] { typeof(bool), typeof(byte[]), typeof(byte[]), typeof(int), typeof(int) };
MethodInfo encryptOrDecryptData = machineKeySection.GetMethod("EncryptOrDecryptData", BindingFlags.Static | BindingFlags.NonPublic, null, paramTypes, null);
return (byte[])encryptOrDecryptData.Invoke(null, new object[] { true, password, null, 0, password.Length });
}