List of usage examples for org.springframework.security.crypto.codec Hex encode
public static char[] encode(byte[] bytes)
From source file:com.ram.topup.business.service.security.encoder.SaltedSHA256PasswordEncoder.java
@Override public String encode(CharSequence rawPassword) { String saltedPassword = rawPassword + this.salt; try {/*from w w w . j a v a 2s.c o m*/ return new String(Hex.encode(this.digest.digest(saltedPassword.getBytes("UTF-8")))); } catch (UnsupportedEncodingException e) { throw new RuntimeException("UTF-8 not supported"); } }
From source file:cn.edu.zjnu.acm.judge.security.password.MessageDigestPasswordEncoder.java
@Override public String encode(CharSequence password) { MessageDigest digest = getMessageDigest(algorithm); return new String(Hex.encode(digest .digest(password != null ? password.toString().getBytes(StandardCharsets.UTF_8) : new byte[0]))); }
From source file:io.pivotal.cla.security.GitHubSignature.java
@SneakyThrows public String create(String body, String token) { return SIGNATURE_PREFIX + new String(Hex.encode(sign(body, token))); }
From source file:org.cloudfoundry.identity.uaa.authentication.RubyUserTokenTests.java
@Test public void sigHasExpectedValue() throws Exception { UserToken ut = new UserToken("joe", 10001323447076L, macKey); assertEquals("a200221c1b5685c7fa8d9995720f2c8c4d85822f", new String(Hex.encode(ut.signature))); }
From source file:org.cloudfoundry.identity.uaa.authentication.RubyUserTokenTests.java
@Test public void rubyGeneratedTokenDecodesOk() throws Exception { UserToken ut = UserToken.decode(TOKEN, macKey); assertEquals("joe", ut.getUsername()); assertEquals(10001323447076L, ut.getValidUntil()); assertEquals("a200221c1b5685c7fa8d9995720f2c8c4d85822f", new String(Hex.encode(ut.signature))); }
From source file:com.boxedfolder.carrot.config.security.xauth.TokenUtils.java
private String computeSignature(UserDetails userDetails, long expires) { StringBuilder signatureBuilder = new StringBuilder(); signatureBuilder.append(userDetails.getUsername()).append(":"); signatureBuilder.append(expires).append(":"); signatureBuilder.append(userDetails.getPassword()).append(":"); signatureBuilder.append(TokenUtils.MAGIC_KEY); MessageDigest digest;//w ww .ja v a 2 s. com try { digest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("No MD5 algorithm available!"); } return new String(Hex.encode(digest.digest(signatureBuilder.toString().getBytes()))); }
From source file:com.javiermoreno.springboot.mvc.users.DailyUser.java
public void setPlainTextPassword(String plainTextPassword) { try {//from ww w. j a v a 2 s . c o m byte[] bytesOfMessage = plainTextPassword.getBytes("UTF-8"); MessageDigest md = MessageDigest.getInstance("MD5"); byte[] thedigest = md.digest(bytesOfMessage); this.passwordHash = new String(Hex.encode(thedigest)); } catch (UnsupportedEncodingException | NoSuchAlgorithmException ex) { throw new RuntimeException(ex); } }
From source file:no.ntnu.okse.core.topic.Topic.java
/** * Private method that generates an MD5 topic ID * * @return A string containing the generated topicID *//* w w w .j a va2 s.c om*/ private String generateTopicID() { try { MessageDigest m = MessageDigest.getInstance("MD5"); m.update(Long.toString(System.nanoTime()).getBytes()); byte[] hash = m.digest(); String topicID = new String(Hex.encode(hash)); return topicID; } catch (NoSuchAlgorithmException e) { log.error("Could not generate a topic ID (MD5 algorithm not found)"); } return null; }
From source file:com.springsource.greenhouse.account.GreenhousePasswordEncoder.java
private String encode(CharSequence rawPassword, byte[] salt) { byte[] digest = digest(rawPassword, salt); return new String(Hex.encode(digest)); }
From source file:grails.plugin.springsecurity.authentication.encoding.DigestAuthPasswordEncoder.java
protected String md5Hex(final String s) { MessageDigest digest;//from www . jav a 2s . c o m try { digest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("No MD5 algorithm available!"); } return new String(Hex.encode(digest.digest(s.getBytes()))); }