我正在开发一个应用程序,它使用用户位置信息将数据发送到服务器。服务器根据校验和计算接受此数据,这是用 java 编写的。
这是用Java编写的代码:
private static final String CHECKSUM_CONS = "1217278743473774374";
private static String createChecksum(double lat, double lon) {
int latLon = (int) ((lat + lon) * 1E6);
String checkSumStr = CHECKSUM_CONS + latLon;
byte buffer[] = checkSumStr.getBytes();
ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
CheckedInputStream cis = new CheckedInputStream(bais, new Adler32());
byte readBuffer[] = new byte[50];
long value = 0;
try {
while (cis.read(readBuffer) >= 0) {
value = cis.getChecksum().getValue();
}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
return String.valueOf(value);
}
我尝试寻求帮助以了解如何编写与此等效的目标 c。上面的函数使用adler32,我对此一无所知。请帮忙。
谢谢你的时间。