當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。