下面这些代码谁给解释一下,bSource, bResult, bResult1,bKey各自的值等于多少
public String KiEncrypt(String strKey, String strSource)
strKey=08ABCDEF673498ADCB23EDF65ADEC12456ADB12E845BC68D
strSource=6FF3F93F4DDD853FA146A9716E
{
crypt cy = new crypt();
Tools tool = new Tools();
byte bSource[] = new byte[8];
byte bResult[] = new byte[8];
byte bResult1[] = new byte[16];
byte bKey[] = new byte[24];
if(strKey.length() == 24)
bKey = strKey.getBytes();
else
if(strKey.length() == 48 && !tool.HexStringToByte(strKey, bKey))
return "0000000000000000";
String strRes = "";
if(!tool.HexStringToByte(strSource, bSource))
return "0000000000000000";
int i = 0;
i = cy.Encrypt(bKey, bSource, bResult, true);
if(i > 0)
{
tool.ByteToHexString(bResult, bResult1);
08ABCDEF,
strRes = new String(bResult1);
} else
{
strRes = Integer.toString(i);
}
return strRes;
}最后得到7B0E7A0A03EF3134,这个是怎么来的? public boolean HexStringToByte(String strSource, byte pbyResult[])
{
int nDataLen = strSource.length();
int nLength = pbyResult.length;
if(0 != nDataLen % 2 || nLength < nDataLen / 2)
return false;
byte pbyData[] = strSource.getBytes();
for(int i = 0; i < nDataLen / 2; i++)
{
byte byHight = pbyData[2 * i];
byte byLow = pbyData[2 * i + 1];
if(byHight > 57)
if(byHight <= 70)
byHight -= 7;
else
byHight -= 39;
if(byLow > 57)
if(byLow <= 70)
byLow -= 7;
else
byLow -= 39;
pbyResult[i] = (byte)((byHight << 4) + (byLow & 0xf));
} return true;
} public boolean ByteToHexString(byte pbySource[], byte pbyResult[])
{
if(pbyResult.length < pbySource.length * 2)
return false;
for(int i = 0; i < pbySource.length; i++)
{
byte byTemp = (byte)(pbySource[i] & 0xf0);
byTemp >>= 4;
byTemp &= 0xf;
if(byTemp <= 9)
pbyResult[2 * i] = (byte)(byTemp + 48);
else
pbyResult[2 * i] = (byte)(byTemp + 55);
byTemp = (byte)(pbySource[i] & 0xf);
if(byTemp <= 9)
pbyResult[2 * i + 1] = (byte)(byTemp + 48);
else
pbyResult[2 * i + 1] = (byte)(byTemp + 55);
} return true;
} private static boolean m_bPrintDebugInfo = false;}
public String KiEncrypt(String strKey, String strSource)
strKey=08ABCDEF673498ADCB23EDF65ADEC12456ADB12E845BC68D
strSource=6FF3F93F4DDD853FA146A9716E
{
crypt cy = new crypt();
Tools tool = new Tools();
byte bSource[] = new byte[8];
byte bResult[] = new byte[8];
byte bResult1[] = new byte[16];
byte bKey[] = new byte[24];
if(strKey.length() == 24)
bKey = strKey.getBytes();
else
if(strKey.length() == 48 && !tool.HexStringToByte(strKey, bKey))
return "0000000000000000";
String strRes = "";
if(!tool.HexStringToByte(strSource, bSource))
return "0000000000000000";
int i = 0;
i = cy.Encrypt(bKey, bSource, bResult, true);
if(i > 0)
{
tool.ByteToHexString(bResult, bResult1);
08ABCDEF,
strRes = new String(bResult1);
} else
{
strRes = Integer.toString(i);
}
return strRes;
}最后得到7B0E7A0A03EF3134,这个是怎么来的? public boolean HexStringToByte(String strSource, byte pbyResult[])
{
int nDataLen = strSource.length();
int nLength = pbyResult.length;
if(0 != nDataLen % 2 || nLength < nDataLen / 2)
return false;
byte pbyData[] = strSource.getBytes();
for(int i = 0; i < nDataLen / 2; i++)
{
byte byHight = pbyData[2 * i];
byte byLow = pbyData[2 * i + 1];
if(byHight > 57)
if(byHight <= 70)
byHight -= 7;
else
byHight -= 39;
if(byLow > 57)
if(byLow <= 70)
byLow -= 7;
else
byLow -= 39;
pbyResult[i] = (byte)((byHight << 4) + (byLow & 0xf));
} return true;
} public boolean ByteToHexString(byte pbySource[], byte pbyResult[])
{
if(pbyResult.length < pbySource.length * 2)
return false;
for(int i = 0; i < pbySource.length; i++)
{
byte byTemp = (byte)(pbySource[i] & 0xf0);
byTemp >>= 4;
byTemp &= 0xf;
if(byTemp <= 9)
pbyResult[2 * i] = (byte)(byTemp + 48);
else
pbyResult[2 * i] = (byte)(byTemp + 55);
byTemp = (byte)(pbySource[i] & 0xf);
if(byTemp <= 9)
pbyResult[2 * i + 1] = (byte)(byTemp + 48);
else
pbyResult[2 * i + 1] = (byte)(byTemp + 55);
} return true;
} private static boolean m_bPrintDebugInfo = false;}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货