using System;
namespace UcAspClass
{
/// <summary>
/// Encrypt 密码加密算法
/// http://www.hzren.net http://www.ucasp.net
/// 作者:QQ 36279010
/// </summary>
public class Encrypt
{
public Encrypt()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static string encrypt(string word)
{
string Password=null;
int CodeLen=30;
int CodeSpace;
double NewCode;
byte[] chr={21};
CodeSpace=CodeLen-word.Length;
if(CodeSpace>=1)
{
for(int i=0;i<CodeSpace;i++)
{
word=word+System.Text.Encoding.Default.GetChars(chr)[0].ToString();
}
}
NewCode=1;
int Been;
for(int i=0;i<CodeLen;i++)
{
Been=CodeLen+System.Text.Encoding.Default.GetBytes(word)[i]*(i+1);
NewCode=NewCode*Been;
}
word=NewCode.ToString();
string newcode=null;
for(int i=0;i<=word.Length-3;i++)
{
newcode=newcode+Hex(word.Substring(i,3));
}
newcode=newcode=newcode+Hex(word.Substring(word.Length-2,2));
newcode=newcode=newcode+Hex(word.Substring(word.Length-1,1));
System.Web.HttpContext.Current.Response.Write(newcode);
for(int i=19;i<newcode.Length-18;i=i+2)
{
Password=Password+newcode.Substring(i,1);
}
return Password;
}
/// <summary>
/// Hex转换为16进制结果
/// </summary>
/// <param name="word">我懒数据转换就用了string 但是一定数值</param>
/// <returns>16进制结果</returns>
private static string Hex(string word)
{
string CfsCode="";
for(int i=0;i<word.ToString().Length;i++)
{
CfsCode=CfsCode+System.Text.Encoding.Default.GetBytes(word.ToString())[i].ToString();
}
return Convert.ToInt64(CfsCode).ToString("X");
}
}
}
namespace UcAspClass
{
/// <summary>
/// Encrypt 密码加密算法
/// http://www.hzren.net http://www.ucasp.net
/// 作者:QQ 36279010
/// </summary>
public class Encrypt
{
public Encrypt()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static string encrypt(string word)
{
string Password=null;
int CodeLen=30;
int CodeSpace;
double NewCode;
byte[] chr={21};
CodeSpace=CodeLen-word.Length;
if(CodeSpace>=1)
{
for(int i=0;i<CodeSpace;i++)
{
word=word+System.Text.Encoding.Default.GetChars(chr)[0].ToString();
}
}
NewCode=1;
int Been;
for(int i=0;i<CodeLen;i++)
{
Been=CodeLen+System.Text.Encoding.Default.GetBytes(word)[i]*(i+1);
NewCode=NewCode*Been;
}
word=NewCode.ToString();
string newcode=null;
for(int i=0;i<=word.Length-3;i++)
{
newcode=newcode+Hex(word.Substring(i,3));
}
newcode=newcode=newcode+Hex(word.Substring(word.Length-2,2));
newcode=newcode=newcode+Hex(word.Substring(word.Length-1,1));
System.Web.HttpContext.Current.Response.Write(newcode);
for(int i=19;i<newcode.Length-18;i=i+2)
{
Password=Password+newcode.Substring(i,1);
}
return Password;
}
/// <summary>
/// Hex转换为16进制结果
/// </summary>
/// <param name="word">我懒数据转换就用了string 但是一定数值</param>
/// <returns>16进制结果</returns>
private static string Hex(string word)
{
string CfsCode="";
for(int i=0;i<word.ToString().Length;i++)
{
CfsCode=CfsCode+System.Text.Encoding.Default.GetBytes(word.ToString())[i].ToString();
}
return Convert.ToInt64(CfsCode).ToString("X");
}
}
}