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


Java Util.getMD5Digest方法代碼示例

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


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

示例1: getInstanceHash

import edu.umd.cs.findbugs.util.Util; //導入方法依賴的package包/類
/**
 * @return Returns the instanceHash.
 */

public String getInstanceHash() {
    String hash = instanceHash;
    if (hash != null)
        return hash;

    MessageDigest digest = Util.getMD5Digest();
    String key = getInstanceKey();
    byte[] data;
    try {
        data = digest.digest(key.getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
        throw new IllegalStateException(e);
    }
    hash = new BigInteger(1, data).toString(16);
    instanceHash = hash;
    return hash;
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:22,代碼來源:BugInstance.java

示例2: computeHash

import edu.umd.cs.findbugs.util.Util; //導入方法依賴的package包/類
/**
 * Compute hash on given method.
 * 
 * @param method
 *            the method
 * @return this object
 */
public MethodHash computeHash(Method method) {
    final MessageDigest digest = Util.getMD5Digest();

    byte[] code;
    if (method.getCode() == null || method.getCode().getCode() == null) {
        code = new byte[0];
    } else {
        code = method.getCode().getCode();
    }

    BytecodeScanner.Callback callback = new BytecodeScanner.Callback() {
        public void handleInstruction(int opcode, int index) {
            digest.update((byte) opcode);
        }
    };

    BytecodeScanner bytecodeScanner = new BytecodeScanner();
    bytecodeScanner.scan(code, callback);

    hash = digest.digest();

    return this;
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:31,代碼來源:MethodHash.java

示例3: main

import edu.umd.cs.findbugs.util.Util; //導入方法依賴的package包/類
public static void main(String args[]) throws Exception {
    FindBugs.setNoAnalysis();
    CountClassVersionsCommandLine commandLine = new CountClassVersionsCommandLine();
    int argCount = commandLine.parse(args, 0, Integer.MAX_VALUE, "Usage: " + CountClassVersions.class.getName()
            + " [options] [<jarFile>+] ");

    int analysisClassCount = 0;
    List<String> fileList;

    if (commandLine.inputFileList != null)
        fileList = readFrom(UTF8.fileReader(commandLine.inputFileList));
    else if (argCount == args.length)
        fileList = readFromStandardInput();
    else
        fileList = Arrays.asList(args).subList(argCount, args.length - 1);
    byte buffer[] = new byte[8192];
    MessageDigest digest = Util.getMD5Digest();
    DualKeyHashMap<String, String, String> map = new DualKeyHashMap<String, String, String>();

    for (String fInName : fileList) {
        File f = new File(fInName);
        if (f.lastModified() < commandLine.maxAge) {
            System.err.println("Skipping " + fInName + ", too old (" + new Date(f.lastModified()) + ")");
            continue;
        }
        System.err.println("Opening " + f);
        ZipFile zipInputFile;
        try {
            zipInputFile = new ZipFile(f);
        } catch (IOException e) {
            e.printStackTrace();
            continue;
        }

        for (Enumeration<? extends ZipEntry> e = zipInputFile.entries(); e.hasMoreElements();) {
            ZipEntry ze = e.nextElement();

            if (ze == null)
                break;
            if (ze.isDirectory())
                continue;

            String name = ze.getName();
            if (!name.endsWith(".class"))
                continue;
            if (!name.replace('/', '.').startsWith(commandLine.prefix))
                continue;

            InputStream zipIn = zipInputFile.getInputStream(ze);

            while (true) {
                int bytesRead = zipIn.read(buffer);
                if (bytesRead < 0)
                    break;
                digest.update(buffer, 0, bytesRead);

            }
            String hash = new BigInteger(1, digest.digest()).toString(16);
            map.put(name, hash, fInName);
        }
        zipInputFile.close();
    }
    for (String s : map.keySet()) {
        Map<String, String> values = map.get(s);
        if (values.size() > 1) {
            System.out.println(values.size() + "\t" + s + "\t" + values.values());
        }

    }
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:71,代碼來源:CountClassVersions.java


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