新编码算法
https://572327713.iteye.com/admin/blogs/2434187
try { byte[] sourceBytes = new byte[8]; if (id < 100000000) { int2bytes(sourceBytes, id); } else { sourceBytes[0] = (byte) ((id >> 24) & 0xFF); sourceBytes[1] = (byte) ((id >> 16) & 0xFF); sourceBytes[2] = (byte) ((id >> 8) & 0xFF); sourceBytes[3] = (byte) ((id) & 0xFF); sourceBytes[4] = Byte.MAX_VALUE; sourceBytes[5] = Byte.MAX_VALUE; sourceBytes[6] = Byte.MAX_VALUE; sourceBytes[7] = Byte.MAX_VALUE; } byte[] encryptedBytes = blowfish.encrypt(sourceBytes); char[] base64Chars = Base64.encode(encryptedBytes); int i; for (i = 0; i < base64Chars.length; i++) { if (base64Chars[i] == '=') { break; // = only appear at end, so i is the ending } else if (base64Chars[i] == '+') { base64Chars[i] = '-'; } else if (base64Chars[i] == '/') { base64Chars[i] = '_'; } } return new String(base64Chars, 0, i); } catch (Exception e) { logger.error("encode error, id=" + id, e); } return null;
相关推荐
湾区人工智能 2020-11-20
Pokemogo 2020-11-16
baijingjing 2020-11-16
baijingjing 2020-11-15
Site 2020-11-07
lwnylslwnyls 2020-11-06
justaipanda 2020-11-05
MachineIntellect 2020-11-02
xueyuediana 2020-10-30
GeraldJones 2020-10-30
Tips 2020-10-29
baijingjing 2020-10-28
baijingjing 2020-10-27
硕鼠 2020-10-26
playoffs 2020-10-26
scuyxi 2020-10-25
playoffs 2020-10-25
yise001 2020-10-23