List of usage examples for org.apache.commons.codec.digest DigestUtils sha256Hex
public static String sha256Hex(String data)
From source file:com.screenslicer.common.Random.java
public static String next() { return DigestUtils.sha256Hex(Long.toString(rand.nextLong())); }
From source file:au.edu.ausstage.utils.HashUtils.java
/** * A method to hash a string/*from w ww . java 2s .c om*/ * * @param data the data to hash * * @return the hashed data */ public static String hashValue(String data) { if (InputUtils.isValid(data) == false) { throw new IllegalArgumentException("The value to be hashed cannot be null or an empty string"); } // return the hashed value return DigestUtils.sha256Hex(data); }
From source file:de.bessonov.auth.dao.UserModel.java
public static String cryptPass(String password) { // easy encrypt return DigestUtils.sha256Hex(password); }
From source file:net.bryansaunders.jee6divelog.util.HashUtils.java
/** * Hashes the string using SHA-256 Algorithim. * //ww w. ja v a2s .com * @param stringToHash * String to hash * @return Hashed String */ public static String toSha256(final String stringToHash) { return DigestUtils.sha256Hex(stringToHash); }
From source file:ApplicationDao.CustomerDao.java
public void insertCustomer(Customer Customer) { Customer.setPassword(DigestUtils.sha256Hex(Customer.getPassword())); em.getTransaction().begin();/*from w w w . j ava 2s . c o m*/ em.persist(Customer); em.getTransaction().commit(); }
From source file:at.fhjoanneum.ima.swenga.webshop.facades.CustomerFacade.java
@Override public void edit(Customer entity) { if (entity.getId() == null) { entity.setPassword(DigestUtils.sha256Hex(entity.getPassword())); } else {// w ww . ja va 2s .co m Customer old = this.find(entity.getId()); if (!old.getPassword().equals(entity.getPassword())) { entity.setPassword(DigestUtils.sha256Hex(entity.getPassword())); } } super.edit(entity); //To change body of generated methods, choose Tools | Templates. }
From source file:com.qwazr.utils.test.DigestUtilsTest.java
@Test public void sha256test() { Assert.assertEquals(hash, DigestUtils.sha256Hex(value)); }
From source file:be.isl.desamouryv.sociall.service.PasswordGeneratorImpl.java
@Override public Password createPassword(String pwd) throws Exception { if (pwd == null) { return null; }//w w w. ja v a2 s.c o m String salt = tokenGenerator.generateSalt(); // TODO //String sha256hex = DigestUtils.sha256Hex(pwd + salt); String sha256hex = DigestUtils.sha256Hex(pwd.getBytes("UTF-8")); Password password = new Password(); password.setHashed(sha256hex); password.setSalt(salt); return password; }
From source file:com.github.aynu.yukar.baseline.provider.domain.auth.CertificationDomainTest.java
@Test public final void test() { final Certification user1 = new Certification("user#1", DigestUtils.sha256Hex("password#1")); LOG.debug("user1 : {}", user1); final CertificationDomain testee = new CertificationDomain(user1); try {//from w w w. j av a2s . co m testee.changePassword(null); fail(); } catch (final NullPointerException e) { LOG.debug(e.toString()); } try { testee.changePassword(StringUtils.EMPTY); fail(); } catch (final IllegalArgumentException e) { LOG.debug(e.toString()); } try { testee.changePassword("password#1"); fail(); } catch (final IllegalArgumentException e) { LOG.debug(e.toString()); } final Certification user2 = testee.changePassword("password#2"); assertThat(user2, is(not(user1))); LOG.debug("user2 : {}", user1); }
From source file:com.acme.legacy.app.manager.SimplePasswordEncoder.java
@Override public String encode(String rawPassword, String salt) { return DigestUtils.sha256Hex(rawPassword + salt); }