List of usage examples for org.apache.shiro.crypto CipherService decrypt
ByteSource decrypt(byte[] encrypted, byte[] decryptionKey) throws CryptoException;
From source file:co.runrightfast.core.security.crypto.impl.EncryptionServiceImpl.java
License:Apache License
private Map<String, CipherFunctions> cipherFunctions(@NonNull final CipherService cipherService, final Map<String, Key> secretKeys) { final ImmutableMap.Builder<String, CipherFunctions> map = ImmutableMap.builder(); secretKeys.entrySet().stream().forEach(entry -> { final byte[] secretKey = entry.getValue().getEncoded(); final Encryption encryption = data -> { try { return cipherService.encrypt(data, secretKey).getBytes(); } catch (final Exception e) { throw new EncryptionServiceException(e); }// w w w .ja v a 2s .c o m }; final Decryption decryption = data -> { try { return cipherService.decrypt(data, secretKey).getBytes(); } catch (final Exception e) { throw new EncryptionServiceException(e); } }; map.put(entry.getKey(), new CipherFunctions(encryption, decryption)); }); return map.build(); }