哪位大神会c#,帮忙翻译成delphi,谢谢!

park689 2017-11-14 12:32:26
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;
}
}
...全文
273 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
大致就是把字符串转成字节数组,加密解密。
Pipi0714 2017-11-15
  • 打赏
  • 举报
回复
哪行不知道啥意思,问问还行!
Pipi0714 2017-11-15
  • 打赏
  • 举报
回复
自己装个环境,调试下就知道了。然后改写成delphi的。 太费时间!

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧