本文整理汇总了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;
}
示例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;
}
示例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());
}
}
}