List of usage examples for org.apache.shiro.codec CodecSupport toString
protected String toString(Object o)
From source file:cn.powerdash.libsystem.common.security.util.CryptoUtil.java
License:Open Source License
public static String decrypt(String cipherText, String key) { AesCipherService aesCs = new AesCipherService(); byte[] keyBytes = CodecSupport.toBytes(key); ByteSource decryptedBytes = aesCs.decrypt(Base64.decode(CodecSupport.toBytes(cipherText)), keyBytes); return CodecSupport.toString(decryptedBytes.getBytes()); }
From source file:de.dominikschadow.javasecurity.symmetric.AES.java
License:Apache License
private static void printReadableMessages(String initialText, byte[] ciphertext, byte[] plaintext) { log.info("initialText: {}", initialText); log.info("cipherText as byte[]: {}", new String(ciphertext)); log.info("cipherText as HEX: {}", Hex.encodeToString(ciphertext)); log.info("plaintext: {}", CodecSupport.toString(plaintext)); }
From source file:de.dominikschadow.javasecurity.symmetric.AESEncryptionSample.java
License:Apache License
private void printReadableMessages(String initialText, byte[] ciphertext, byte[] plaintext) { logger.info("initialText: {}", initialText); logger.info("cipherText as byte[]: {}", new String(ciphertext)); logger.info("cipherText as Base64: {}", Base64.encodeToString(ciphertext)); logger.info("plaintext: {}", CodecSupport.toString(plaintext)); }
From source file:org.obiba.mica.micaConfig.service.MicaConfigService.java
License:Open Source License
public String decrypt(String encrypted) { try {/* w w w.ja v a 2s . c om*/ ByteSource decrypted = cipherService.decrypt(Hex.decode(encrypted), getSecretKey()); return CodecSupport.toString(decrypted.getBytes()); } catch (CryptoException e) { logger.warn(String.format("Someone tried to use an invalid key [%s]", encrypted)); throw new IllegalArgumentException("Given key is invalid", e); } }
From source file:org.obiba.opal.core.service.security.CryptoServiceImpl.java
License:Open Source License
@Override public String decrypt(String encrypted) { ByteSource decrypted = cipherService.decrypt(Hex.decode(encrypted), getSecretKey()); return CodecSupport.toString(decrypted.getBytes()); }
From source file:org.pepstock.jem.node.resources.ResourcesUtil.java
License:Open Source License
/** * Decrypts a secret//from ww w . ja v a 2s.co m * * @param cryptedValue encrypted value * @param hash hash string to check if secret is correct * @return secret in clear * @throws NodeMessageException */ public String decrypt(String cryptedValue, String hash) throws NodeMessageException { try { Sha256Hash hasher = new Sha256Hash(cryptedValue); String valueHashed = hasher.toBase64(); if (!valueHashed.equalsIgnoreCase(hash)) { throw new NodeMessageException(NodeMessage.JEMC118E); } byte[] decryptBytes = Crypto.decrypt(Base64.decodeBase64(cryptedValue), key); return CodecSupport.toString(decryptBytes); } catch (KeyException e) { throw new NodeMessageException(NodeMessage.JEMC118E, e); } }