List of usage examples for org.apache.commons.codec.digest DigestUtils md5
public static byte[] md5(String data)
From source file:com.vmware.o11n.plugin.crypto.service.CryptoDigestService.java
public String md5(String data) { return Base64.encodeBase64String(DigestUtils.md5(data)); }
From source file:io.cloudslang.content.database.utils.TripleDES.java
public static byte[] md5Hash(@NotNull final String toHash) { byte[] digest = DigestUtils.md5(toHash.getBytes()); byte[] key = new byte[24]; System.arraycopy(digest, 0, key, 0, 16); System.arraycopy(digest, 0, key, 16, 8); return key;/*from ww w . ja v a2s . c o m*/ }
From source file:com.ai.smart.bottom.helper.MacUtils.java
public static String hmacsha256(String secret, String data) { Mac mac = null;// ww w . j a v a 2 s .com byte[] doFinal = null; try { mac = Mac.getInstance(HMAC_ALGORITHM); //??MD5 byte[] dataBytes = DigestUtils.md5(data); //sourcekeyMD5, SecretKey secretkey = new SecretKeySpec(DigestUtils.md5(secret), HMAC_ALGORITHM); mac.init(secretkey); //HmacSHA256 doFinal = mac.doFinal(dataBytes); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } catch (InvalidKeyException e) { } String checksum = Hex.encodeHexString(doFinal).toLowerCase(); return checksum; }
From source file:com.open.cas.shiro.util.EncodeUtils.java
public static byte[] md5(String input) { return DigestUtils.md5(input); }
From source file:kltn.dao.UserDAO.java
public boolean login(String username, String password) { Session session = HibernateUtil.getSessionFactory().openSession(); String md5 = new BigInteger(DigestUtils.md5(password)).toString(16); System.out.println(md5);/*from w ww . j a v a 2 s. c o m*/ List<String> list = null; Transaction tx = null; try { tx = session.beginTransaction(); Criteria cr = session.createCriteria(User.class); cr.add(Restrictions.eq("username", username)); cr.add(Restrictions.eq("password", md5)); list = cr.list(); System.out.println(list.size()); tx.commit(); } catch (HibernateException he) { if (tx != null && tx.isActive()) { tx.rollback(); } } finally { session.close(); } return (list.size() == 1); }
From source file:com.vmware.o11n.plugin.crypto.service.CryptoDigestService.java
public String md5Base64(String dataB64) { validateB64(dataB64); return Base64.encodeBase64String(DigestUtils.md5(Base64.decodeBase64(dataB64))); }
From source file:com.open.cas.shiro.util.EncodeUtils.java
public static String base64md5(String input) { return Base64.encodeBase64String(DigestUtils.md5(input)); }
From source file:fr.free.nrw.commons.Utils.java
/** * Creates an URL for thumbnail//from w w w .j a v a 2 s .com * * @param filename Thumbnail file name * @return URL of thumbnail */ public static String makeThumbBaseUrl(@NonNull String filename) { String name = new PageTitle(filename).getPrefixedText(); String sha = new String(Hex.encodeHex(DigestUtils.md5(name))); return String.format("%s/%s/%s/%s", BuildConfig.IMAGE_URL_BASE, sha.substring(0, 1), sha.substring(0, 2), urlEncode(name)); }
From source file:edu.psu.citeseerx.utility.FileDigest.java
/** * Calculates the MD5 digest of the file an d returns the value as a 16 element * <code>byte[]</code>.//from w w w.jav a 2 s . c o m * @param toDigest Data to digest * @return MD5 digest */ public static byte[] md5(File toDigest) { byte[] fileContent = getFileContent(toDigest); return DigestUtils.md5(fileContent); }
From source file:com.haulmont.timesheets.EncryptDecrypt.java
public EncryptDecrypt(String key) { try {//from w ww . j a v a2 s . co m String data = new StringBuilder(SALT + key).reverse().toString(); SecretKeySpec secretKey = new SecretKeySpec(DigestUtils.md5(data), "AES"); AlgorithmParameterSpec paramSpec = new IvParameterSpec(INIT_VECTOR); eCipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); dCipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); eCipher.init(Cipher.ENCRYPT_MODE, secretKey, paramSpec); dCipher.init(Cipher.DECRYPT_MODE, secretKey, paramSpec); } catch (Exception e) { throw new RuntimeException("Exception while init cipher:", e); } }