A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://kasparov.skife.org/blog/src/java/jce-openssl-redux.html below:

Brian McCallister

Re: JCE and OpenSSL

Thank you Julius Davies! for not-yet-commons-ssl which does exactly what I was looking for

import org.apache.commons.io.IOUtils;
import org.apache.commons.ssl.OpenSSL;

import java.io.File;
import java.io.FileOutputStream;

public class Foo
{
    public static void main(String[] args) throws Exception
    {
        File f = new File("/tmp/foo");
        FileOutputStream fout = new FileOutputStream(f);
        fout.write(OpenSSL.encrypt("aes256", 
                                   "secret".toCharArray(), 
                                   "hello world\n".getBytes("UTF-8")));
        fout.close();
        Process p = Runtime.getRuntime()
            .exec("openssl enc -pass pass:secret -d -aes256 -a -in /tmp/foo");
        System.out.print(IOUtils.toString(p.getInputStream()));
    }
}

Woo hoo!

3 writebacks [/src/java] permanent link


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4