From: Bernhard Wieser <Bernhard.Wieser@cgy.valmet.com>
To: "'java-security@java.sun.com.'" <java-security@java.sun.com>
Subject: examples
Date: Thu, 3 Jun 1999 14:15:33 -0600
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() );
}
}
}