小编use*_*097的帖子

目标c中的adler32校验和

我正在开发一个应用程序,它使用用户位置信息向服务器发送数据.服务器接受基于校验和计算的数据,这是用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);
} …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c adler32 ios

0
推荐指数
1
解决办法
1036
查看次数

标签 统计

adler32 ×1

ios ×1

iphone ×1

objective-c ×1