当前位置: 首页>>代码示例>>Java>>正文


Java HashFunction.hashString方法代码示例

本文整理汇总了Java中com.google.common.hash.HashFunction.hashString方法的典型用法代码示例。如果您正苦于以下问题:Java HashFunction.hashString方法的具体用法?Java HashFunction.hashString怎么用?Java HashFunction.hashString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.hash.HashFunction的用法示例。


在下文中一共展示了HashFunction.hashString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getJarFilePrefix

import com.google.common.hash.HashFunction; //导入方法依赖的package包/类
/**
 * Files exported from jars are exported into a certain folder so that we can rebuild them
 * when the related jar file changes.
 */
@NonNull
private static String getJarFilePrefix(@NonNull File inputFile) {
    // get the filename
    String name = inputFile.getName();
    // remove the extension
    int pos = name.lastIndexOf('.');
    if (pos != -1) {
        name = name.substring(0, pos);
    }

    // add a hash of the original file path.
    String input = inputFile.getAbsolutePath();
    HashFunction hashFunction = Hashing.sha1();
    HashCode hashCode = hashFunction.hashString(input, Charsets.UTF_16LE);

    return name + "-" + hashCode.toString();
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:22,代码来源:AwbDataBindingMergeArtifactsTask.java

示例2: getDirectoryNameForJar

import com.google.common.hash.HashFunction; //导入方法依赖的package包/类
/**
 * Chooses a directory name, based on a JAR file name, considering exploded-aar and classes.jar.
 */

public static String getDirectoryNameForJar(File inputFile) {
    // add a hash of the original file path.
    HashFunction hashFunction = Hashing.sha1();
    HashCode hashCode = hashFunction.hashString(inputFile.getAbsolutePath(), Charsets.UTF_16LE);

    String name = Files.getNameWithoutExtension(inputFile.getName());
    if (name.equals("classes") && inputFile.getAbsolutePath().contains("exploded-aar")) {
        // This naming scheme is coming from DependencyManager#computeArtifactPath.
        File versionDir = inputFile.getParentFile().getParentFile();
        File artifactDir = versionDir.getParentFile();
        File groupDir = artifactDir.getParentFile();

        name = Joiner.on('-').join(
                groupDir.getName(), artifactDir.getName(), versionDir.getName());
    }
    name = name + "_" + hashCode.toString();
    return name;
}
 
开发者ID:dodola,项目名称:AnoleFix,代码行数:23,代码来源:FileUtils.java

示例3: getJackFileName

import com.google.common.hash.HashFunction; //导入方法依赖的package包/类
/**
 * Returns a unique File for the converted library, even if there are 2 libraries with the same
 * file names (but different paths)
 *
 * @param outFolder the output folder.
 * @param inputFile the library
 */
@NonNull
public static File getJackFileName(@NonNull File outFolder, @NonNull File inputFile) {
    // get the filename
    String name = inputFile.getName();
    // remove the extension
    int pos = name.lastIndexOf('.');
    if (pos != -1) {
        name = name.substring(0, pos);
    }

    // add a hash of the original file path.
    String input = inputFile.getAbsolutePath();
    HashFunction hashFunction = Hashing.sha1();
    HashCode hashCode = hashFunction.hashString(input, Charsets.UTF_16LE);

    return new File(outFolder, name + "-" + hashCode.toString() + SdkConstants.DOT_JAR);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:JillTask.java

示例4: getDirectoryNameForJar

import com.google.common.hash.HashFunction; //导入方法依赖的package包/类
/**
 * Chooses a directory name, based on a JAR file name, considering exploded-aar and classes.jar.
 */
@NonNull
public static String getDirectoryNameForJar(@NonNull File inputFile) {
    // add a hash of the original file path.
    HashFunction hashFunction = Hashing.sha1();
    HashCode hashCode = hashFunction.hashString(inputFile.getAbsolutePath(), Charsets.UTF_16LE);

    String name = Files.getNameWithoutExtension(inputFile.getName());
    if (name.equals("classes") && inputFile.getAbsolutePath().contains("exploded-aar")) {
        // This naming scheme is coming from DependencyManager#computeArtifactPath.
        File versionDir = inputFile.getParentFile().getParentFile();
        File artifactDir = versionDir.getParentFile();
        File groupDir = artifactDir.getParentFile();

        name = Joiner.on('-').join(
                groupDir.getName(), artifactDir.getName(), versionDir.getName());
    }
    name = name + "_" + hashCode.toString();
    return name;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:23,代码来源:FileUtils.java

示例5: getDexFileName

import com.google.common.hash.HashFunction; //导入方法依赖的package包/类
private String getDexFileName(File inputFile) {
    // get the filename
    String name = inputFile.getName();
    // remove the extension
    int pos = name.lastIndexOf('.');
    if (pos != -1) {
        name = name.substring(0, pos);
    }

    // add a hash of the original file path
    HashFunction hashFunction = Hashing.md5();
    HashCode hashCode = hashFunction.hashString(inputFile.getAbsolutePath(), Charsets.UTF_16LE);

    return name + "-" + hashCode.toString() + ".jar";
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:DexExecTask.java

示例6: password

import com.google.common.hash.HashFunction; //导入方法依赖的package包/类
public static HashCode password(final String username) {
  HashFunction _md5 = Hashing.md5();
  return _md5.hashString(username);
}
 
开发者ID:East196,项目名称:maker,代码行数:5,代码来源:Randoms.java

示例7: testMd5

import com.google.common.hash.HashFunction; //导入方法依赖的package包/类
@Test
public void testMd5() {
	HashFunction md5 = Hashing.md5();
	HashCode hashString = md5.hashString("BeforeHash", Charset.defaultCharset());
	assertEquals("86b3a7bd44852cf9cc897e262ccb4edd", hashString.toString());
}
 
开发者ID:szaqal,项目名称:KitchenSink,代码行数:7,代码来源:TestHashing.java

示例8: testSha512

import com.google.common.hash.HashFunction; //导入方法依赖的package包/类
@Test
public void testSha512() {
	HashFunction sha512 = Hashing.sha512();
	HashCode hashString = sha512.hashString("BeforeHash", Charset.defaultCharset());
	assertEquals("12ccc1ec7265c18840ab0b5b70b8b776fca4015f3ed62eb0d2c2bf727fe8e108b77e9f49458e47e98d852861b8a0bb83a9b5dd4fe84f89ce3d5fe6623142426f", hashString.toString());
}
 
开发者ID:szaqal,项目名称:KitchenSink,代码行数:7,代码来源:TestHashing.java

示例9: getIPHash

import com.google.common.hash.HashFunction; //导入方法依赖的package包/类
public static String getIPHash() {

		// IP address is mixed with the users home directory, 
		// so that it can't be decrypted by the server.

		String text = DataSources.EXTERNAL_IP + System.getProperty("user.home");

		HashFunction hf = Hashing.md5();
		HashCode hc = hf.hashString(text, Charsets.UTF_8);

		String ipHash = hc.toString();

		return ipHash;
	}
 
开发者ID:dessalines,项目名称:torrenttunes-client,代码行数:15,代码来源:Tools.java

示例10: HashGraph

import com.google.common.hash.HashFunction; //导入方法依赖的package包/类
/**
 * Create a blank HashGraph
 * @param hf The hashing function to be used
 */
public HashGraph(HashFunction hf){
	this(hf, new ArrayList<Node[]>(), new HashMap<Node,HashCode>(), hf.hashString("", Charsets.UTF_8), new HashMap<Node,HashCode>());
}
 
开发者ID:aidhog,项目名称:blabel,代码行数:8,代码来源:HashGraph.java

示例11: newHash

import com.google.common.hash.HashFunction; //导入方法依赖的package包/类
/**
 * Creates a UTF-8 encoded hash using the hash function
 *
 * @param input string to encode
 * @param function hash function to use
 * @return the hash code
 */
public static HashCode newHash(String input, HashFunction function) {
    return function.hashString(input, Charsets.UTF_8);
}
 
开发者ID:pawelprazak,项目名称:java-extended,代码行数:11,代码来源:Hash.java


注:本文中的com.google.common.hash.HashFunction.hashString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。