谁能提供一个库,我看到 chinapay 有提供 Red hat Linux 的 库 so 的,不知道 ruby 怎么调用 或者调用 dll 库也行
我研究了一下库的源码,主要就是一个 buildkey 的方法,还有就是 sign 的方法
public bool buildKey(string MerID, int KeyUsage, string KeyFile)
{
byte[] array = new byte[8];
bool result = false;
StreamReader streamReader = new StreamReader(KeyFile);
try
{
string text = streamReader.ReadLine();
if (text.CompareTo("[SecureLink]") == 0 || text.CompareTo("[NetPayClient]") == 0)
{
text = streamReader.ReadLine();
int num = text.IndexOf("=");
string text2 = text.Substring(0, num);
text = text.Substring(num + 1);
if (text.CompareTo(MerID) == 0)
{
if (KeyUsage == 0)
{
text = streamReader.ReadLine();
text = text.Substring(8);
}
else
{
text = streamReader.ReadLine();
text = streamReader.ReadLine();
text = text.Substring(8);
}
byte[] array2 = new byte[712];
if (text.Length > 0)
{
array2 = NetPay.Asc2Hex(text);
}
if (text2.CompareTo("PGID") != 0)
{
byte[] array3 = new byte[64];
byte[] array4 = new byte[64];
byte[] array5 = new byte[64];
byte[] array6 = new byte[64];
byte[] array7 = new byte[64];
this.memset(array, 0, array.Length);
this.des.cbc_encrypt(array2, 424u, 64u, array3, 0u, array, false);
this.memset(array, 0, array.Length);
this.des.cbc_encrypt(array2, 488u, 64u, array4, 0u, array, false);
this.memset(array, 0, array.Length);
this.des.cbc_encrypt(array2, 552u, 64u, array5, 0u, array, false);
this.memset(array, 0, array.Length);
this.des.cbc_encrypt(array2, 616u, 64u, array6, 0u, array, false);
this.memset(array, 0, array.Length);
this.des.cbc_encrypt(array2, 680u, 64u, array7, 0u, array, false);
this.rsaPrivateKey = new RSAPrivateKey();
this.rsaPrivateKey.p = new BigInteger(array3);
this.rsaPrivateKey.q = new BigInteger(array4);
this.rsaPrivateKey.u = new BigInteger(array7);
this.rsaPrivateKey.dP = new BigInteger(array5);
this.rsaPrivateKey.dQ = new BigInteger(array6);
this.PrivateKeyFlag = true;
result = true;
}
else
{
byte[] array8 = new byte[128];
byte[] array9 = new byte[128];
Array.ConstrainedCopy(array2, 24, array8, 0, 128);
Array.ConstrainedCopy(array2, 152, array9, 0, 128);
this.rsaPublicKey = new RSAPublicKey();
this.rsaPublicKey.n = new BigInteger(array8);
this.rsaPublicKey.e = new BigInteger(array9);
this.PublicKeyFlag = true;
result = true;
}
}
}
}
catch (Exception)
{
return result;
}
finally
{
streamReader.Close();
}
return result;
}
我想如果用 ruby 改写下,以后 netpayclient 升级,我还需要修改,不如可以调用它的库方便,求大神指点下,谢谢了!