当前位置: 首页>>代码示例>>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;未经允许,请勿转载。