public String createSha1(File file) throws TechnicalException {
try (InputStream fis = new FileInputStream(file);) {
MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
int n = 0;
byte[] buffer = new byte[8192];
while (n != -1) {
n = fis.read(buffer);
if (n > 0) {
sha1.update(buffer, 0, n);
}
}
return new HexBinaryAdapter().marshal(sha1.digest());
} catch (NoSuchAlgorithmException | IOException e) {
throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_CHECKSUM_IO_EXCEPTION), e);
}
}
java类javax.xml.bind.annotation.adapters.HexBinaryAdapter的实例源码
Security.java 文件源码
项目:NoraUi
阅读 27
收藏 0
点赞 0
评论 0
CommandInvite.java 文件源码
项目:CreeperHostGui
阅读 21
收藏 0
点赞 0
评论 0
private void inviteUser(GameProfile profile)
{
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
Gson gson = new Gson();
UserListWhitelist whitelistedPlayers = server.getConfigurationManager().func_152599_k();
final ArrayList<String> tempHash = new ArrayList<String>();
String name = profile.getName().toLowerCase();
try
{
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(whitelistedPlayers.func_152706_a(name).getId().toString().getBytes(Charset.forName("UTF-8")));
tempHash.add((new HexBinaryAdapter()).marshal(hash));
}
catch (NoSuchAlgorithmException e)
{
e.printStackTrace();
}
CreeperHostServer.InviteClass invite = new CreeperHostServer.InviteClass();
invite.hash = tempHash;
invite.id = CreeperHostServer.updateID;
Util.putWebResponse("https://api.creeper.host/serverlist/invite", gson.toJson(invite), true, true);
}
CommandInvite.java 文件源码
项目:CreeperHostGui
阅读 19
收藏 0
点赞 0
评论 0
private void removeUser(GameProfile profile)
{
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
Gson gson = new Gson();
final ArrayList<String> tempHash = new ArrayList<String>();
try
{
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(profile.getId().toString().getBytes(Charset.forName("UTF-8")));
tempHash.add((new HexBinaryAdapter()).marshal(hash));
}
catch (NoSuchAlgorithmException e)
{
e.printStackTrace();
}
CreeperHostServer.InviteClass invite = new CreeperHostServer.InviteClass();
invite.hash = tempHash;
invite.id = CreeperHostServer.updateID;
CreeperHostServer.logger.debug("Sending " + gson.toJson(invite) + " to revoke endpoint");
String resp = Util.putWebResponse("https://api.creeper.host/serverlist/revokeinvite", gson.toJson(invite), true, true);
CreeperHostServer.logger.debug("Response from revoke endpoint " + resp);
}
Callbacks.java 文件源码
项目:CreeperHostGui
阅读 18
收藏 0
点赞 0
评论 0
public static String getPlayerHash(UUID uuid)
{
if (hashCache.containsKey(uuid))
return hashCache.get(uuid);
String playerHash;
try
{
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(uuid.toString().getBytes(Charset.forName("UTF-8")));
playerHash = (new HexBinaryAdapter()).marshal(hash);
}
catch (NoSuchAlgorithmException e)
{
e.printStackTrace();
return null;
}
hashCache.put(uuid, playerHash);
return playerHash;
}
Callbacks.java 文件源码
项目:CreeperHostGui
阅读 19
收藏 0
点赞 0
评论 0
public static String getPlayerHash(UUID uuid)
{
if (hashCache.containsKey(uuid))
return hashCache.get(uuid);
String playerHash;
try
{
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(uuid.toString().getBytes(Charset.forName("UTF-8")));
playerHash = (new HexBinaryAdapter()).marshal(hash);
}
catch (NoSuchAlgorithmException e)
{
e.printStackTrace();
return null;
}
hashCache.put(uuid, playerHash);
return playerHash;
}
Strings.java 文件源码
项目:fort_j
阅读 17
收藏 0
点赞 0
评论 0
@ApiMethod
@Comment(value = "Hash the bytes with the given algorithm")
public static String hash(byte[] byteArr, String algorithm)
{
try
{
MessageDigest digest = MessageDigest.getInstance(algorithm);
digest.update(byteArr);
byte[] bytes = digest.digest();
String hex = (new HexBinaryAdapter()).marshal(bytes);
return hex;
}
catch (Exception ex)
{
Lang.rethrow(ex);
}
return null;
}
HashUtils.java 文件源码
项目:EMC
阅读 24
收藏 0
点赞 0
评论 0
public static String calcSHA(File file) throws Exception {
MessageDigest sha1 = MessageDigest.getInstance("SHA-512");
InputStream input = new FileInputStream(file);
try {
byte[] buffer = new byte[8192];
int len = input.read(buffer);
while (len != -1) {
sha1.update(buffer, 0, len);
len = input.read(buffer);
}
input.close();
return new HexBinaryAdapter().marshal(sha1.digest());
} catch (Exception ex) {
return "";
}
}
DumpSocat.java 文件源码
项目:docker-network-veth
阅读 21
收藏 0
点赞 0
评论 0
public static void main(String[] args) throws IOException {
final byte[] bytes2 = Base64.getDecoder().decode("YnsLfVSN");
System.out.println(new HexBinaryAdapter().marshal(bytes2));
if(true) {
return;
}
String filename = "/Users/esinev/Library/Preferences/IdeaIC15/scratches/docker-create-endpoint.txt";
LineNumberReader reader = new LineNumberReader(new FileReader(filename));
String line;
while (( line = reader.readLine()) != null) {
// System.out.println(line);
if(line.length() >= 50 && line.charAt(48) == ' ' && line.charAt(49) == ' ') {
String hex = line.substring(0, 49);
final byte[] bytes = new HexBinaryAdapter().unmarshal(hex.replace(" ", ""));
String value = new String(bytes);
System.out.print(value);
// line = line.substring(50);
} else {
System.out.println(line);
}
// System.out.println(line);
}
}
OracleConverterTest.java 文件源码
项目:blade-jdbc
阅读 21
收藏 0
点赞 0
评论 0
@Test
public void testUUIDConverter() throws ConverterException {
UUID uuid = UUID.randomUUID();
OracleQuirks orclQuirks = new OracleQuirks();
Converter<UUID> uuidConverter = new OracleUUIDConverter();
byte[] rawUuid = (byte[])uuidConverter.toDatabaseParam(uuid);
UUID reconvertedUuid = uuidConverter.convert(rawUuid);
assertEquals(uuid, reconvertedUuid);
// convert bytes to hex and put hyphens into the string to recreate the UUID string representation, just to be
// sure everything is done correct.
String hex = new HexBinaryAdapter().marshal(rawUuid);
String hexUuid = String.format("%s-%s-%s-%s-%s",
hex.substring(0,8),
hex.substring(8,12),
hex.substring(12, 16),
hex.substring(16, 20),
hex.substring(20)).toLowerCase();
assertEquals(uuid.toString(), hexUuid);
}
DuplicatedFiles.java 文件源码
项目:KeepTry
阅读 19
收藏 0
点赞 0
评论 0
private String sha2OfBigger(File f) {
try (FileChannel ch = new RandomAccessFile(f, "r").getChannel()) {
int size = (int) Math.min(f.length(), Integer.MAX_VALUE);
MappedByteBuffer byteBuffer // 2G
= ch.map(FileChannel.MapMode.READ_ONLY, 0, size);
MessageDigest sha2 = MessageDigest.getInstance("SHA-256");
long offset = 0;
byte[] array = new byte[Integer.MAX_VALUE >> 2];
while (size != 0) {
while (byteBuffer.remaining() > 0) {
int numInArray = Math.min(array.length, byteBuffer.remaining());
byteBuffer.get(array, 0, numInArray);
sha2.update(array, 0, numInArray);
}
offset += size;
size = (int) Math.min(Integer.MAX_VALUE, f.length() - offset);
byteBuffer = ch.map(FileChannel.MapMode.READ_ONLY, offset, size);
}
return new HexBinaryAdapter().marshal(sha2.digest());
} catch (IOException | NoSuchAlgorithmException e) {
e.printStackTrace();
return "\\";
}
}
DuplicatedFiles.java 文件源码
项目:KeepTry
阅读 20
收藏 0
点赞 0
评论 0
private String sha2Of(File file) {
if (file.length() > Integer.MAX_VALUE >> 2) {
return sha2OfBigger(file);
}
try (FileChannel ch = new FileInputStream(file).getChannel()) {
byte[] arry = new byte[1024 * 8];
ByteBuffer byteBuffer = ByteBuffer.wrap(arry);
int size = ch.read(byteBuffer);
MessageDigest sha2 = MessageDigest.getInstance("SHA-256");
while (size != -1) {
sha2.update(arry, 0, size);
byteBuffer.rewind();
size = ch.read(byteBuffer);
}
return new HexBinaryAdapter().marshal(sha2.digest());
} catch (IOException | NoSuchAlgorithmException e) {
e.printStackTrace();
return "\\";
}
}
Sha1OfFile.java 文件源码
项目:KeepTry
阅读 28
收藏 0
点赞 0
评论 0
private static String calcSHA1(File file) throws
IOException, NoSuchAlgorithmException {
MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); // todo algorithm here??
try (InputStream input = new FileInputStream(file)) {
byte[] buffer = new byte[1024 * 8];
int len = input.read(buffer);
while (len != -1) {
sha1.update(buffer, 0, len);
len = input.read(buffer);
}
return new HexBinaryAdapter().marshal(sha1.digest());
}
}
Parcel.java 文件源码
项目:cloudera-parcel
阅读 16
收藏 0
点赞 0
评论 0
private String calculateSha1(File file) throws MojoExecutionException {
InputStream input = null;
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
input = new FileInputStream(file);
byte[] buffer = new byte[8192];
int len;
while ((len = input.read(buffer)) != -1) {
messageDigest.update(buffer, 0, len);
}
return new HexBinaryAdapter().marshal(messageDigest.digest());
} catch (Exception exception) {
throw new MojoExecutionException("Could not create SHA1 of file [" + file + "]");
} finally {
IOUtils.closeQuietly(input);
}
}
ChecksumHelper.java 文件源码
项目:backblaze-b2-java-api
阅读 24
收藏 0
点赞 0
评论 0
/**
* Calculate and return the sha1 sum of an input stream
*
* @param in the input stream to calculate the sha1 sum of
*
* @return the sha1 sum
*
* @throws IOException if there was an error calculating the sha1 sum
*/
public static String calculateSha1(InputStream in) throws IOException {
MessageDigest messageDigest;
InputStream inputStream = null;
try {
messageDigest = MessageDigest.getInstance("SHA-1");
inputStream = new BufferedInputStream(in);
byte[] buffer = new byte[8192];
int len = inputStream.read(buffer);
while (len != -1) {
messageDigest.update(buffer, 0, len);
len = inputStream.read(buffer);
}
return(new HexBinaryAdapter().marshal(messageDigest.digest()));
} catch (NoSuchAlgorithmException ex) {
throw new IOException(ex);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
TransactionSignTest.java 文件源码
项目:Shufflepuff
阅读 18
收藏 0
点赞 0
评论 0
@Test
public void testSigning() throws AddressFormatException {
NetworkParameters netParams = TestNet3Params.get();
HexBinaryAdapter adapter = new HexBinaryAdapter();
Context context = Context.getOrCreate(netParams);
byte[] bx = adapter.unmarshal("0100000001bd5ee90ffe5eedd67c09c3bb348dd7dc1308800eb221b1c92dda651010519ba3010000006a4730440220467868c0b2ed001a915cca5269b928698bee8aba4fe454e1d775070d9e4041cb02205d1c979dbc75e5dc656c4e9d5969d716a383797bd5ad5df79a13d0d6e3f51ccb012102403adb7674f25212bc8cf4a97797154a4980c60e9f328c90300b71a8a04389c7ffffffff024088db60000000001976a914990628d3670f439a5f9e0dfa6492b8bbf3b3fa1b88ac76cf6edd050000001976a914b679378d01ee7203a454bca2ad25698ef23a056388ac00000000");
org.bitcoinj.core.Transaction testbx = new org.bitcoinj.core.Transaction(netParams, bx);
org.bitcoinj.core.Transaction tx = new org.bitcoinj.core.Transaction(netParams);
tx.addOutput(org.bitcoinj.core.Coin.SATOSHI.multiply(testbx.getOutput(0).getValue().value - 50000l), new Address(netParams, "mobDb19geJ66kkQnsSYvN9PNEKNDiNBHEp"));
System.out.println(testbx.getOutput(0));
tx.addInput(testbx.getOutput(0));
String seckey = "3EC95EBFEDCF77373BABA0DE345A0962E51344CD2D0C8DBDF93AEFD0B66BE240";
byte[] privkey = Hex.decode(seckey);
ECKey ecPriv = ECKey.fromPrivate(privkey);
Sha256Hash hash2 = tx.hashForSignature(0, testbx.getOutput(0).getScriptPubKey().getProgram(), Transaction.SigHash.ALL, false);
ECKey.ECDSASignature ecSig = ecPriv.sign(hash2);
TransactionSignature txSig = new TransactionSignature(ecSig, Transaction.SigHash.ALL, false);
Script inputScript = ScriptBuilder.createInputScript(txSig, ECKey.fromPublicOnly(ecPriv.getPubKey()));
tx.getInput(0).setScriptSig(inputScript);
String hexBin = DatatypeConverter.printHexBinary(tx.bitcoinSerialize());
System.out.println(hexBin);
tx.getInput(0).verify(testbx.getOutput(0));
// SUCCESSFULLY BROADCAST WOO!
}
SWAMTOMPortTypeImpl.java 文件源码
项目:wso2-axis2
阅读 22
收藏 0
点赞 0
评论 0
/**
* This method passes an SWA attachment as a request
* and expects an SWA attachment as a response.
* Note that the body content in both cases is empty.
* (See the wsdl)
* @param attachment (swa)
* @return attachment (swa)
*/
@WebMethod(operationName="swaAttachment", action="swaAttachment")
@XmlJavaTypeAdapter(HexBinaryAdapter.class)
@WebResult(name = "jpegImageResponse", targetNamespace = "", partName = "jpegImageResponse")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public byte[] swaAttachment(
@XmlJavaTypeAdapter(HexBinaryAdapter.class)
@WebParam(name = "jpegImageRequest", targetNamespace = "", partName = "jpegImageRequest")
byte[] attachment) {
if (attachment == null || attachment.length == 0){
throw new RuntimeException("Received empty attachment");
} else {
// Change the first three characters and return the attachment
attachment[0] = 'S';
attachment[1] = 'W';
attachment[2] = 'A';
}
return attachment;
}
VaultOdvExporter.java 文件源码
项目:OpenDiabetes
阅读 21
收藏 0
点赞 0
评论 0
@Override
protected void writeToFile(List<ExportEntry> csvEntries) throws IOException {
// Setup compression stuff
ZipOutputStream zos = new ZipOutputStream(fileOutpuStream);
zos.setMethod(ZipOutputStream.DEFLATED);
zos.setLevel(9);
// Setup signature stuff
MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-512");
} catch (NoSuchAlgorithmException ex) {
LOG.log(Level.SEVERE, "Missing hash algorithm for signature. No file exported!", ex);
throw new IOException("Missing hash algorithm for signature.");
}
DigestOutputStream dos = new DigestOutputStream(zos, md);
// write data
zos.putNextEntry(new ZipEntry(DATA_ZIP_ENTRY));
CsvWriter cwriter = new CsvWriter(dos, VaultCsvEntry.CSV_DELIMITER,
Charset.forName("UTF-8"));
cwriter.writeRecord(((CsvEntry) csvEntries.get(0)).getCsvHeaderRecord());
for (ExportEntry item : csvEntries) {
cwriter.writeRecord(((CsvEntry) item).toCsvRecord());
}
cwriter.flush();
// add signature file
zos.putNextEntry(new ZipEntry(SIGNATURE_ZIP_ENTRY));
String sigString = (new HexBinaryAdapter()).marshal(md.digest());
zos.write(sigString.getBytes(), 0, sigString.getBytes().length);
// close everything
cwriter.close();
dos.close();
zos.close();
fileOutpuStream.close();
}
CommandInvite.java 文件源码
项目:CreeperHostGui
阅读 22
收藏 0
点赞 0
评论 0
private void inviteUser(GameProfile profile)
{
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
Gson gson = new Gson();
UserListWhitelist whitelistedPlayers = server.getPlayerList().getWhitelistedPlayers();
final ArrayList<String> tempHash = new ArrayList<String>();
String name = profile.getName().toLowerCase();
try
{
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(whitelistedPlayers.getByName(name).getId().toString().getBytes(Charset.forName("UTF-8")));
tempHash.add((new HexBinaryAdapter()).marshal(hash));
}
catch (NoSuchAlgorithmException e)
{
e.printStackTrace();
}
CreeperHostServer.InviteClass invite = new CreeperHostServer.InviteClass();
invite.hash = tempHash;
invite.id = CreeperHostServer.updateID;
CreeperHostServer.logger.debug("Sending " + gson.toJson(invite) + " to add endpoint");
String resp = Util.putWebResponse("https://api.creeper.host/serverlist/invite", gson.toJson(invite), true, true);
CreeperHostServer.logger.debug("Response from add endpoint " + resp);
}
CommandInvite.java 文件源码
项目:CreeperHostGui
阅读 22
收藏 0
点赞 0
评论 0
private void removeUser(GameProfile profile)
{
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
Gson gson = new Gson();
final ArrayList<String> tempHash = new ArrayList<String>();
try
{
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(profile.getId().toString().getBytes(Charset.forName("UTF-8")));
String hashString = (new HexBinaryAdapter()).marshal(hash);
CreeperHostServer.logger.info("Removing player with hash " + hashString);
tempHash.add(hashString);
}
catch (NoSuchAlgorithmException e)
{
e.printStackTrace();
}
CreeperHostServer.InviteClass invite = new CreeperHostServer.InviteClass();
invite.hash = tempHash;
invite.id = CreeperHostServer.updateID;
CreeperHostServer.logger.debug("Sending " + gson.toJson(invite) + " to revoke endpoint");
String resp = Util.putWebResponse("https://api.creeper.host/serverlist/revokeinvite", gson.toJson(invite), true, true);
CreeperHostServer.logger.debug("Response from revoke endpoint " + resp);
}
TightCouplingProcessor.java 文件源码
项目:service-block-samples
阅读 18
收藏 0
点赞 0
评论 0
/**
* Converts an arbitrary message into an MD5 hash and returns it as a UTF-8 encoded string
*
* @param message is the message to convert
* @return a UTF-8 encoded string representation of the MD5 hash
*/
String getMd5Hash(String message) {
String result;
try {
MessageDigest md5 = MessageDigest.getInstance(MD5);
result = (new HexBinaryAdapter()).marshal(md5.digest(message.getBytes())).toLowerCase();
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Error converting message to MD5 hash", e);
}
return result;
}
MD5Authentication.java 文件源码
项目:reactive-pg-client
阅读 25
收藏 0
点赞 0
评论 0
public static String encode(String username, String password, byte[] salt) {
HexBinaryAdapter hex = new HexBinaryAdapter();
byte[] digest, passDigest;
MessageDigest messageDigest;
try {
messageDigest = MessageDigest.getInstance("MD5");
}
catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
messageDigest.update(password.getBytes(UTF_8));
messageDigest.update(username.getBytes(UTF_8));
digest = messageDigest.digest();
byte[] hexDigest = hex.marshal(digest).toLowerCase().getBytes(US_ASCII);
messageDigest.update(hexDigest);
messageDigest.update(salt);
passDigest = messageDigest.digest();
return "md5" + hex.marshal(passDigest).toLowerCase();
}
Crypto.java 文件源码
项目:lockd
阅读 23
收藏 0
点赞 0
评论 0
public static String sha256hash(String plaintext) {
try{
MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
//Converting from bytes to hex
return (new HexBinaryAdapter()).marshal(sha256.digest(plaintext.getBytes("UTF-8")));
} catch(Exception e) {
System.out.println("Error while hashing: " + e.toString());
}
return null;
}
Utils.java 文件源码
项目:camel-isds
阅读 21
收藏 0
点赞 0
评论 0
/**
* Compute md5 hash of given stream
*
* @param stream stream to hash
* @return hex string md5 hash
* @throws NoSuchAlgorithmException
* @throws IOException
*/
public static String md5HashStream(InputStream stream) throws NoSuchAlgorithmException, IOException {
MessageDigest digest = MessageDigest.getInstance("MD5");
try (DigestInputStream expectDigestStream = new DigestInputStream(stream, digest)) {
int read = 0;
while ((read = expectDigestStream.read()) >= 0) {
// don't care about the data
}
}
return new HexBinaryAdapter().marshal(digest.digest());
}
Utils.java 文件源码
项目:EsupUserApps
阅读 23
收藏 0
点赞 0
评论 0
static String computeMD5(String s) {
try {
//System.out.println("computing digest of " + file);
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] digest = md.digest(s.getBytes());
return (new HexBinaryAdapter()).marshal(digest);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
Config.java 文件源码
项目:DBforBIX
阅读 24
收藏 0
点赞 0
评论 0
public static String calculateMD5Sum(String inStr) {
MessageDigest hasher = null;
try{
hasher = java.security.MessageDigest.getInstance("MD5");
}
catch(NoSuchAlgorithmException e){
LOG.error("Wrong hashing algorithm name provided while getting instance of MessageDigest: " + e.getLocalizedMessage());
}
return (new HexBinaryAdapter()).marshal(hasher.digest(inStr.getBytes()));
}
Tool.java 文件源码
项目:Project-Alpha
阅读 27
收藏 0
点赞 0
评论 0
public static String hash(String text) {
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(text.getBytes());
byte[] hashBytes = md.digest();
String hashedText = (new HexBinaryAdapter().marshal(hashBytes));
return hashedText.toLowerCase();
}
catch (NoSuchAlgorithmException e) {
System.out.println("Algorithm not found.");
}
return null;
}
UniformRapidSuspensionCommand.java 文件源码
项目:nomulus
阅读 21
收藏 0
点赞 0
评论 0
private ImmutableSortedSet<String> getExistingDsData(DomainResource domain) {
ImmutableSortedSet.Builder<String> dsDataJsons = ImmutableSortedSet.naturalOrder();
HexBinaryAdapter hexBinaryAdapter = new HexBinaryAdapter();
for (DelegationSignerData dsData : domain.getDsData()) {
dsDataJsons.add(JSONValue.toJSONString(ImmutableMap.of(
"keyTag", dsData.getKeyTag(),
"algorithm", dsData.getAlgorithm(),
"digestType", dsData.getDigestType(),
"digest", hexBinaryAdapter.marshal(dsData.getDigest()))));
}
return dsDataJsons.build();
}
UniformRapidSuspensionCommandTest.java 文件源码
项目:nomulus
阅读 18
收藏 0
点赞 0
评论 0
private void persistDomainWithHosts(HostResource... hosts) {
ImmutableSet.Builder<Key<HostResource>> hostRefs = new ImmutableSet.Builder<>();
for (HostResource host : hosts) {
hostRefs.add(Key.create(host));
}
persistResource(newDomainResource("evil.tld").asBuilder()
.setNameservers(hostRefs.build())
.setDsData(ImmutableSet.of(
DelegationSignerData.create(1, 2, 3, new HexBinaryAdapter().unmarshal("dead")),
DelegationSignerData.create(4, 5, 6, new HexBinaryAdapter().unmarshal("beef"))))
.build());
}
HybridbpmCoreUtil.java 文件源码
项目:hybridbpm
阅读 21
收藏 0
点赞 0
评论 0
public static String hashPassword(String password) {
try {
MessageDigest md = MessageDigest.getInstance("SHA-512");
md.update(password.getBytes("UTF-8"));
byte[] bytes = md.digest();
return (new HexBinaryAdapter()).marshal(bytes);
} catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
logger.severe(ex.getMessage());
}
return null;
}
HybridbpmCoreUtil.java 文件源码
项目:hybridbpm
阅读 18
收藏 0
点赞 0
评论 0
public static String generateToken(String username) throws NoSuchAlgorithmException, UnsupportedEncodingException {
try {
SecureRandom random = new SecureRandom();
String token_data = UUID.randomUUID().toString() + username + System.nanoTime() + new BigInteger(32, random).toString(32);
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(token_data.getBytes("UTF-8"));
byte[] bytes = md.digest();
return new HexBinaryAdapter().marshal(bytes);
} catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
logger.severe(ex.getMessage());
}
return null;
}