use of aQute.libg.cryptography.MD5 in project bnd by bndtools.
the class MavenFileRepository method store.
@Override
public void store(File source, String path) throws Exception {
if (!source.isFile())
throw new IllegalArgumentException("File does not exist: " + source);
File dest = getFile(path);
IO.mkdirs(dest.getParentFile());
IO.copy(source, dest);
SHA1 sha1 = SHA1.digest(source);
MD5 md5 = MD5.digest(source);
IO.store(sha1.asHex() + "\n", new File(dest.getParentFile(), dest.getName() + ".sha1"));
IO.store(md5.asHex() + "\n", new File(dest.getParentFile(), dest.getName() + ".md5"));
}
use of aQute.libg.cryptography.MD5 in project bnd by bndtools.
the class MavenRemoteRepository method store.
public void store(File file, String path) throws Exception {
int n = 0;
URL url = new URL(base + path);
SHA1 sha1 = SHA1.digest(file);
MD5 md5 = MD5.digest(file);
try (TaggedData go = client.build().put().upload(file).updateTag().asTag().go(url)) {
switch(go.getState()) {
case NOT_FOUND:
case OTHER:
throw new IOException("Could not store " + path + " from " + file + " with " + go);
case UNMODIFIED:
case UPDATED:
default:
break;
}
}
try (TaggedData tag = client.build().put().upload(sha1.asHex()).asTag().go(new URL(base + path + ".sha1"))) {
}
try (TaggedData tag = client.build().put().upload(md5.asHex()).asTag().go(new URL(base + path + ".md5"))) {
}
}
use of aQute.libg.cryptography.MD5 in project bnd by bndtools.
the class Analyzer method _md5.
public String _md5(String[] args) throws Exception {
Macro.verifyCommand(args, _md5Help, new Pattern[] { null, null, Pattern.compile("base64|hex") }, 2, 3);
Digester<MD5> digester = MD5.getDigester();
Resource r = dot.getResource(args[1]);
if (r == null)
throw new FileNotFoundException("From " + digester + ", not found " + args[1]);
IO.copy(r.openInputStream(), digester);
boolean hex = args.length > 2 && args[2].equals("hex");
if (hex)
return Hex.toHexString(digester.digest().digest());
return Base64.encodeBase64(digester.digest().digest());
}
Aggregations