Re: examples

Sharon Liu (Sharon.Liu@eng.sun.com)
Thu, 3 Jun 1999 14:56:37 -0700 (PDT)

Message-Id: <199906032159.OAA11878@shorter.eng.sun.com>
Date: Thu, 3 Jun 1999 14:56:37 -0700 (PDT)
From: Sharon Liu <Sharon.Liu@eng.sun.com>
Subject: Re: examples
To: java-security@java.sun.com, Bernhard.Wieser@cgy.valmet.com

Bernhard,

I tried your test program, and it worked fine for me.

Could you please let me know what problems you ran into? Did you
get any exceptions? If so, please let me know what exceptions
you got.

Just double check: have you got the JCE installed at the right
place? Have you registered the JCE provider?

Thanks,
Sharon

> To: "'java-security@java.sun.com.'" <java-security@java.sun.com>
> Subject: examples
>
> Please provide examples, as I have been unable to get even the simplest
> tests working...
> package testjce;
> import java.security.*;
> import javax.swing.*;
> import javax.crypto.*;
> import javax.crypto.spec.*;
>
> public class Application1
> {
>
> static byte [] key={
> (byte)'1',
> (byte)'2',
> (byte)'3',
> (byte)'4',
> (byte)'5',
> (byte)'6',
> (byte)'7',
> (byte)'8' };
>
> static byte [] text={
> (byte)'1',
> (byte)'2',
> (byte)'3',
> (byte)'4',
> (byte)'5',
> (byte)'6',
> (byte)'7',
> (byte)'8' };
>
> // Main entry point
> static public void main(String[] args)
> {
> try{
> Cipher cipher = Cipher.getInstance( "DES" );
> SecretKeyFactory skf = SecretKeyFactory.getInstance( "DES"
> );
> cipher.init( Cipher.ENCRYPT_MODE, skf.generateSecret( new
> DESKeySpec( key ) ) );
> cipher.doFinal( text );
> } catch ( Throwable t )
> {
> System.out.println( t.toString() );
> }
> }
>
> }
>