The Artima Developer Community
Sponsored Link

Java Buzz Forum
Re: JCE and OpenSSL

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Brian McCallister

Posts: 1282
Nickname: frums
Registered: Sep, 2003

Brian McCallister is JustaProgrammer who thinks too much.
Re: JCE and OpenSSL Posted: Dec 7, 2007 4:08 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Brian McCallister.
Original Post: Re: JCE and OpenSSL
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
Latest Java Buzz Posts
Latest Java Buzz Posts by Brian McCallister
Latest Posts From Waste of Time

Advertisement

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!

Read: Re: JCE and OpenSSL

Topic: Microsoft TechEd IT Forum 2007 Wrap-up and Other Videos from PeopleOverProcess.com Previous Topic   Next Topic Topic: August 2007 New Java Performance Tips

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use