class Util
{
private const int PWD_DATA_SIZE = 40;
public static byte[] getPWD(string pwd)
{
//PWD_HS1: IDC_HS1:;
byte[] bpwd = new byte[PWD_DATA_SIZE];
byte[] head = Encoding.ASCII.GetBytes("PWD_HS1:");
byte[] spwd = Encoding.ASCII.GetBytes(pwd);
byte[] temp = new byte[32 - spwd.Length];
byte[] mpwd = MergerArray(spwd, temp);
temp = new byte[32];
Util.FKHS3760_EncryptPwd(ref mpwd, ref temp, 32);
bpwd = MergerArray(head, temp);
return bpwd;
}
public static byte[] MergerArray(byte[] First, byte[] Second)
{
byte[] result = new byte[First.Length + Second.Length];
First.CopyTo(result, 0);
Second.CopyTo(result, First.Length);
return result;
}
public static void FKHS3760_EncryptPwd(ref byte[] apOrgPwdData, ref byte[] apEncPwdData, int aPwdLen)
{
int i;
gPassEncryptKey = 12415;
for (i = 0; i < aPwdLen; i++)
apEncPwdData[i] = Encrypt_1Byte(apOrgPwdData[i]);
}
public static int gPassEncryptKey;
public static byte Encrypt_1Byte(byte aByteData)
{
int U0 = 28904;
int U1 = 35756;
byte vCrytData;
vCrytData = (byte)(aByteData ^ (byte)(gPassEncryptKey >> 8));
gPassEncryptKey = (vCrytData + gPassEncryptKey) * U0 + U1;
return vCrytData;
}
public static void FKHS3760_DecryptPwd(byte[] apEncPwdData,ref byte[] apOrgPwdData, int aPwdLen)
{
int i;
gPassEncryptKey = 12415;
for (i = 0; i < aPwdLen; i++)
apOrgPwdData[i] = Decrypt_1Byte(apEncPwdData[i]);
}
public static byte Decrypt_1Byte(byte aByteData)
{
int U0 = 28904;
int U1 = 35756;
byte vCrytData;
vCrytData = (byte)(aByteData ^ (byte)(gPassEncryptKey >> 8));
gPassEncryptKey = (aByteData + gPassEncryptKey) * U0 + U1;
return vCrytData;
}
}
uj5u.com熱心網友回復:
自己裝個環境,除錯下就知道了。然后改寫成delphi的。太費時間!
uj5u.com熱心網友回復:
哪行不知道啥意思,問問還行!uj5u.com熱心網友回復:
大致就是把字串轉成位元組陣列,加密解密。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/47728.html
標籤:語言基礎/算法/系統設計
上一篇:delphi怎么呼叫這樣的動態庫
