當前位置: 首頁>>代碼示例>>Java>>正文


Java Hashing.md5方法代碼示例

本文整理匯總了Java中com.google.common.hash.Hashing.md5方法的典型用法代碼示例。如果您正苦於以下問題:Java Hashing.md5方法的具體用法?Java Hashing.md5怎麽用?Java Hashing.md5使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.hash.Hashing的用法示例。


在下文中一共展示了Hashing.md5方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: build

import com.google.common.hash.Hashing; //導入方法依賴的package包/類
public CacheEntry build() {
    Path baseDir = cacheDir.resolve(name);
    if (!keys.isEmpty()) {
        HashFunction hf = Hashing.md5();
        Hasher h = hf.newHasher();
        for (String key : keys) {
            h.putString(key, Charsets.UTF_8);
        }
        HashCode hc = h.hash();
        baseDir = baseDir.resolve(hc.toString());
    }
    cacheEntriesLock.lock();
    try {
        CacheEntry cacheEntry = cacheEntries.get(baseDir.toString());
        if (cacheEntry != null) {
            if (!cacheEntry.getKeys().equals(keys)) {
                throw new PowsyblException("Inconsistent hash");
            }
        } else {
            cacheEntry = new CacheEntry(baseDir, keys);
            cacheEntries.put(baseDir.toString(), cacheEntry);
        }
        return cacheEntry;
    } finally {
        cacheEntriesLock.unlock();
    }
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:28,代碼來源:CacheManager.java

示例2: getHardwareProperties

import com.google.common.hash.Hashing; //導入方法依賴的package包/類
/**
 * Returns the hardware properties defined in
 * {@link AvdManager#HARDWARE_INI} as a {@link Map}.
 *
 * This is intended to be dumped in the config.ini and already contains
 * the device name, manufacturer and device hash.
 *
 * @param d The {@link Device} from which to derive the hardware properties.
 * @return A {@link Map} of hardware properties.
 */
@NonNull
public static Map<String, String> getHardwareProperties(@NonNull Device d) {
    Map<String, String> props = getHardwareProperties(d.getDefaultState());
    for (State s : d.getAllStates()) {
        if (s.getKeyState().equals(KeyboardState.HIDDEN)) {
            props.put("hw.keyboard.lid", getBooleanVal(true));
        }
    }

    HashFunction md5 = Hashing.md5();
    Hasher hasher = md5.newHasher();

    ArrayList<String> keys = new ArrayList<String>(props.keySet());
    Collections.sort(keys);
    for (String key : keys) {
        if (key != null) {
            hasher.putString(key, Charsets.UTF_8);
            String value = props.get(key);
            hasher.putString(value == null ? "null" : value, Charsets.UTF_8);
        }
    }
    // store the hash method for potential future compatibility
    String hash = "MD5:" + hasher.hash().toString();
    props.put(AvdManager.AVD_INI_DEVICE_HASH_V2, hash);
    props.remove(AvdManager.AVD_INI_DEVICE_HASH_V1);

    props.put(AvdManager.AVD_INI_DEVICE_NAME, d.getId());
    props.put(AvdManager.AVD_INI_DEVICE_MANUFACTURER, d.getManufacturer());
    return props;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:41,代碼來源:DeviceManager.java

示例3: getHashFor

import com.google.common.hash.Hashing; //導入方法依賴的package包/類
private String getHashFor(File inputFile) {
    String retval = alreadyChecked.get(inputFile.getAbsolutePath());
    if (retval != null) return retval;
    // add a hash of the original file path
    try {
        HashFunction hashFunction = Hashing.md5();
        HashCode hashCode = hashFunction.hashBytes(Files.readAllBytes(inputFile.toPath()));
        retval = hashCode.toString();
        alreadyChecked.put(inputFile.getAbsolutePath(), retval);
        return retval;
    } catch (IOException e) {
        e.printStackTrace();
        return "ERROR";
    }
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:16,代碼來源:DexExecTask.java

示例4: forName

import com.google.common.hash.Hashing; //導入方法依賴的package包/類
public static HashFunction forName(String name) {
    switch (name) {
        case "murmur3_32":
            return Hashing.murmur3_32();
        case "murmur3_128":
            return Hashing.murmur3_128();
        case "crc32":
            return Hashing.crc32();
        case "md5":
            return Hashing.md5();
        default:
            throw new IllegalArgumentException("Can't find hash function with name " + name);
    }
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:15,代碼來源:MiscUtils.java

示例5: forName

import com.google.common.hash.Hashing; //導入方法依賴的package包/類
/** Return the hash function corresponding to a given message-digest algorithm given by name.
 *
 * @param messageDigest a message-digest algorithm (e.g., <code>MurmurHash3</code> or <code>MD5</code>); {@code null} if {@code messageDigest} is the empty string.
 */
@SuppressWarnings("deprecation")
public final static HashFunction forName(final String messageDigest) throws NoSuchAlgorithmException {
	if ("".equals(messageDigest)) return null;
	if ("MD5".equalsIgnoreCase(messageDigest)) return Hashing.md5();
	if ("MurmurHash3".equalsIgnoreCase(messageDigest)) return Hashing.murmur3_128();
	throw new NoSuchAlgorithmException("Unknown hash function " + messageDigest);
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:12,代碼來源:BinaryParser.java

示例6: createCacheKeyBuilder

import com.google.common.hash.Hashing; //導入方法依賴的package包/類
protected CacheKeyBuilder createCacheKeyBuilder(FileHasher fileHasher, ClassPathSnapshotter snapshotter, ClassLoaderHierarchyHasher classLoaderHierarchyHasher) {
    return new DefaultCacheKeyBuilder(Hashing.md5(), fileHasher, snapshotter, classLoaderHierarchyHasher);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:4,代碼來源:CacheRepositoryServices.java


注:本文中的com.google.common.hash.Hashing.md5方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。