Example usage for org.apache.shiro.codec CodecSupport toBytes

List of usage examples for org.apache.shiro.codec CodecSupport toBytes

Introduction

In this page you can find the example usage for org.apache.shiro.codec CodecSupport toBytes.

Prototype

public static byte[] toBytes(String source, String encoding) throws CodecException 

Source Link

Document

Converts the specified source to a byte array via the specified encoding, throwing a CodecException CodecException if the encoding fails.

Usage

From source file:de.elomagic.mag.utils.SimpleCrypt.java

License:Apache License

public static String encrypt(String decrypted) throws IOException {
    try {//from  www .  j av  a 2  s  .  com
        byte[] secretBytes = CodecSupport.toBytes(decrypted, "utf-8");

        ByteSource encrypted = CIPHER.encrypt(secretBytes, getMasterKey());

        return "{" + encrypted.toBase64() + "}";
    } catch (Exception ex) {
        LOGGER.error(ex.getMessage(), ex);
        throw (ex);
    }
}