sig生成方式:key:aUdqk-BvLwKltime:当前时间。(long)num:随机数。(long)SHA1(key+time+num)以java为例:privatestaticStringencrypt(Stringkey,longtimes,longnum){byte[]k=key.ge...
sig生成方式:
key : aUdqk-BvLwKl
time:当前时间。(long)
num:随机数。(long)
SHA1(key+time+num)
以java为例:
private static String encrypt(String key,long times,long num){
byte[] k = key.getBytes();
byte[] t = getBytesByLong(times);
byte[] n = getBytesByLong(num);
byte[] np = new byte[k.length+t.length+n.length];
int i=0;
for(int j=0;j
np[i]=k[j];
}
for(int j=0;j
np[i]=t[j];
}
for(int j=0;j
np[i]=n[j];
}
String sha1 = SHA1Util.getSHA1(np);
return sha1;
}
private static byte[] getBytesByLong(long data){
byte[] bytes = new byte[8];
bytes[0] = (byte) (data & 0xff);
bytes[1] = (byte) ((data >> 8) & 0xff);
bytes[2] = (byte) ((data >> 16) & 0xff);
bytes[3] = (byte) ((data >> 24) & 0xff);
bytes[4] = (byte) ((data >> 32) & 0xff);
bytes[5] = (byte) ((data >> 40) & 0xff);
bytes[6] = (byte) ((data >> 48) & 0xff);
bytes[7] = (byte) ((data >> 56) & 0xff);
return bytes;
}
展开