Examples of CryptoBox


Examples of org.jboss.aerogear.crypto.CryptoBox

     *
     * @throws Exception
     */
    public static String encrypt(final byte[] key, final String content) throws Exception {
        final byte[] iv = BlockCipher.getIV();
        final byte[] encrypted = new CryptoBox(key).encrypt(iv, content.getBytes(ASCII));
        final String base64 = new UrlBase64().encode(prependIV(encrypted, iv));
        return URLEncoder.encode(base64, ASCII.displayName());
    }
View Full Code Here

Examples of org.jboss.aerogear.crypto.CryptoBox

     * @throws Exception
     */
    public static String decrypt(final byte[] key, final String content) throws Exception {
        final byte[] decodedContent = new UrlBase64().decode(URLDecoder.decode(content, ASCII.displayName()));
        final byte[] iv = extractIV(decodedContent);
        final byte[] decrypted = new CryptoBox(key).decrypt(iv, extractContent(decodedContent));
        return new String(decrypted, ASCII);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.