我想在 android 中找到 http 响应的 sha1sum 并使用手动检查该 shasum 结果

I would like to find the sha1sum of a http response in android and checking that shasum result with manual one

HTTP URL: https://raw.github.com/square/okhttp/master/README.md 要从我的系统中查找 SHA1SUM:手动获取邮递员 url 的响应并将响应放入文件中,然后使用以下命令 (linux)

sha1sum 文件名

来自 android 代码:获得 http 同步调用响应后,将该字符串传递给以下方法。

public static String SHA1(String text) {
    Log.d("SHA1:::", ":" + text);
    try {

        MessageDigest md;
        md = MessageDigest.getInstance("SHA-1");
        md.update(text.getBytes("iso-8859-1"),
                0, text.length());
        byte[] sha1hash = md.digest();
        System.out.println(("SHA1:::::" + sha1hash));
        System.out.println(toHex(sha1hash));
        return toHex(sha1hash);

    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    return null;
}

private final static String HEX = "0123456789ABCDEF";

public static String toHex(byte[] buf) {

    if (buf == null) return "";

    int l = buf.length;
    StringBuffer result = new StringBuffer(2 * l);

    for (int i = 0; i < buf.length; i++) {
        appendHex(result, buf[i]);
    }

    return result.toString();

}

但是我从代码和手册中得到了不同的结果sha1sum.Please建议我该怎么做..

我在 question.The sha1sum 中发布的代码是正确的 android 代码是正确的,因为手动 sha1sum wrong.I 采取了 [=21= 的响应] 来自 mozilla 网络浏览器,浏览器截断最后的白线.. 所以 sha1sum 是 incorrect.Now 我正在使用 Chrome 作为响应,sha1sum 与 android 代码 sha1sum 相同.

注意:请使用chrome响应,以便我们可以获得相同的sha1sum..