String hex = (new HexBinaryAdapter()).marshal(md5.digest(YOUR_STRING.getBytes()))
import javax.xml.bind.annotation.adapters.HexBinaryAdapter; public byte[] hexToBytes(String hexString) { HexBinaryAdapter adapter = new HexBinaryAdapter(); byte[] bytes = adapter.unmarshal(hexString); return bytes; }
public static String getHash(String str) { if(str != null) try { MessageDigest md = MessageDigest.getInstance("SHA-256"); return new HexBinaryAdapter().marshal(md.digest(dontRainbowTableMeOrMySonEverAgain(str).getBytes())); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return ""; }
throw new IOException("<xattr> had no <val> or <valHex> entry."); val = new HexBinaryAdapter().unmarshal(valHex); } else { val = valStr.getBytes("UTF8");
String hex = (new HexBinaryAdapter()).marshal(md5.digest(YOUR_STRING.getBytes()))
System.out.println((new HexBinaryAdapter()).marshal(hash));
public synchronized static byte[] hexToBytes(String hexString) { HexBinaryAdapter adapter = new HexBinaryAdapter(); byte[] bytes = adapter.unmarshal(hexString); return bytes; }
/** * Determines the sha1 hash (hex representation) of the data provided by the input stream. */ static String readSha1(InputStream inputStream) throws NoSuchAlgorithmException, IOException { MessageDigest sha1Digest = MessageDigest.getInstance("SHA-1"); byte[] buf = new byte[ANY_SIZE]; int n; while ((n = inputStream.read(buf)) > 0) { sha1Digest.update(buf, 0, n); } return new HexBinaryAdapter().marshal(sha1Digest.digest()); }
public byte[] hexToBytes(String hexString) { HexBinaryAdapter adapter = new HexBinaryAdapter(); byte[] bytes = adapter.unmarshal(hexString); return bytes; } }
public static String bytesToString(byte[] bytes) { HexBinaryAdapter adapter = new HexBinaryAdapter(); String s = adapter.marshal(bytes); return s; }
"lacked a <key> field."); byte[] key = new HexBinaryAdapter().unmarshal(keyHex); dkey.verifyNoRemainingKeys(SECRET_MANAGER_SECTION_DELEGATION_KEY); dbld.setKey(ByteString.copyFrom(key));
public static byte[] hexToBytes(String hexString) { HexBinaryAdapter adapter = new HexBinaryAdapter(); byte[] bytes = adapter.unmarshal(hexString); return bytes; }
public static String hash(String str) { String sHash = ""; try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(str.getBytes()); sHash = (new HexBinaryAdapter()).marshal(md.digest(str.getBytes())); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return sHash; } }
HexBinaryAdapter hba = new HexBinaryAdapter(); String md5 = hba.marshal(s); return md5;
/** * Gets the value of the xorPattern property. * * @return * possible object is * {@link String } * */ public byte[] getXorPattern() { if (xorPattern == null) { return new HexBinaryAdapter().unmarshal("55AA55AA55AA55BB"); } else { return xorPattern; } }
/** * Gets the unique ID. * * @param idstring * the idstring * @return the unique ID */ public static String getUniqueID(String idstring) { try { MessageDigest md5 = MessageDigest.getInstance("MD5"); return (new HexBinaryAdapter()).marshal(md5.digest(idstring.getBytes())); } catch (NoSuchAlgorithmException e) { LOGGER.error("Error in getUniqueID",e); } return ""; }
protected File getDoneFile(URI basedir, URI wsdlURI, String mojo) { String doneFileName = mojo + wsdlURI.toString(); try { MessageDigest cript = MessageDigest.getInstance("SHA-1"); cript.reset(); cript.update(doneFileName.getBytes("utf8")); doneFileName = new javax.xml.bind.annotation.adapters.HexBinaryAdapter().marshal(cript.digest()); } catch (Exception e) { //ignore, we'll try and fake it based on the wsdl // Strip the basedir from the doneFileName if (doneFileName.startsWith(basedir.toString())) { doneFileName = doneFileName.substring(basedir.toString().length()); } // If URL to WSDL, replace ? and & since they're invalid chars for file names // Not to mention slashes. doneFileName = doneFileName.replace('?', '_').replace('&', '_').replace('/', '_').replace('\\', '_') .replace(':', '_'); doneFileName += ".DONE"; } return new File(markerDirectory, "." + doneFileName); }
protected File getDoneFile(URI basedir, URI wsdlURI, String mojo) { String doneFileName = mojo + wsdlURI.toString(); try { MessageDigest cript = MessageDigest.getInstance("SHA-1"); cript.reset(); cript.update(doneFileName.getBytes("utf8")); doneFileName = new javax.xml.bind.annotation.adapters.HexBinaryAdapter().marshal(cript.digest()); } catch (Exception e) { //ignore, we'll try and fake it based on the wsdl // Strip the basedir from the doneFileName if (doneFileName.startsWith(basedir.toString())) { doneFileName = doneFileName.substring(basedir.toString().length()); } // If URL to WSDL, replace ? and & since they're invalid chars for file names // Not to mention slashes. doneFileName = doneFileName.replace('?', '_').replace('&', '_').replace('/', '_').replace('\\', '_') .replace(':', '_'); doneFileName += ".DONE"; } return new File(markerDirectory, "." + doneFileName); }
protected String getMd5Sum(HttpServletRequest request) throws NoSuchAlgorithmException, UnsupportedEncodingException { return new HexBinaryAdapter().marshal(getMd5Digest(request).digest()); }
public MojoliciousFileImpl(@NotNull FileViewProvider viewProvider) { super(viewProvider, MojoliciousLanguage.INSTANCE); VirtualFile virtualFile = getVirtualFile(); String canonicalPath = virtualFile == null ? null : virtualFile.getCanonicalPath(); if (canonicalPath != null) { try { myNamespace = MOJO_SANDBOX_NS_PREFIX + PerlPackageUtil.PACKAGE_SEPARATOR + new HexBinaryAdapter().marshal(MessageDigest.getInstance("MD5").digest(canonicalPath.getBytes())); } catch (NoSuchAlgorithmException ignore) { } } if (myNamespace == null) { myNamespace = MOJO_SANDBOX_NS_PREFIX; } }