com.bumptech.glide.util.Util.sha256BytesToHex()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(209)

本文整理了Java中com.bumptech.glide.util.Util.sha256BytesToHex()方法的一些代码示例,展示了Util.sha256BytesToHex()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.sha256BytesToHex()方法的具体详情如下:
包路径:com.bumptech.glide.util.Util
类名称:Util
方法名:sha256BytesToHex

Util.sha256BytesToHex介绍

[英]Returns the hex string of the given byte array representing a SHA256 hash.
[中]

代码示例

代码示例来源:origin: bumptech/glide

private String calculateHexStringDigest(Key key) {
 PoolableDigestContainer container = Preconditions.checkNotNull(digestPool.acquire());
 try {
  key.updateDiskCacheKey(container.messageDigest);
  // calling digest() will automatically reset()
  return Util.sha256BytesToHex(container.messageDigest.digest());
 } finally {
  digestPool.release(container);
 }
}

代码示例来源:origin: bumptech/glide

String getStringDigest(Key key) {
  return com.bumptech.glide.util.Util.sha256BytesToHex(getDigest(key));
 }
}

代码示例来源:origin: guolindev/giffun

public String getSafeKey(Key key) {
    String safeKey;
    synchronized (loadIdToSafeHash) {
      safeKey = loadIdToSafeHash.get(key);
    }
    if (safeKey == null) {
      try {
        MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
        key.updateDiskCacheKey(messageDigest);
        safeKey = Util.sha256BytesToHex(messageDigest.digest());
      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
      } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
      }
      synchronized (loadIdToSafeHash) {
        loadIdToSafeHash.put(key, safeKey);
      }
    }
    return safeKey;
  }
}

代码示例来源:origin: mozilla-tw/Rocket

private String calculateHexStringDigest(Key key) {
 PoolableDigestContainer container = digestPool.acquire();
 try {
  key.updateDiskCacheKey(container.messageDigest);
  // calling digest() will automatically reset()
  return Util.sha256BytesToHex(container.messageDigest.digest());
 } finally {
  digestPool.release(container);
 }
}

代码示例来源:origin: REBOOTERS/AndroidAnimationExercise

public String getSafeKey(Key key) {
    String safeKey;
    synchronized (loadIdToSafeHash) {
      safeKey = loadIdToSafeHash.get(key);
    }
    if (safeKey == null) {
      try {
        MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
        key.updateDiskCacheKey(messageDigest);
        safeKey = Util.sha256BytesToHex(messageDigest.digest());
      } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
      }
      synchronized (loadIdToSafeHash) {
        loadIdToSafeHash.put(key, safeKey);
      }
    }
    return safeKey;
  }
}

相关文章