Algoritmo Des

Páginas: 2 (269 palabras) Publicado: 1 de agosto de 2012
Algoritmo DES
Descripción:

Paquetes:
Java.security.spec:
Javax.crypto: En este paquete se proporcionan las diferentes operaciones criptográficas

Javax.crypto.spec:import java.security.spec.*;
import javax.crypto.*;
import javax.crypto.spec.*;

class DESTest {public static void main(String[] args) {
String test = "1";
try {
byte[] theKey = null;
byte[]theMsg = null;
byte[] theExp = null;
if (test.equals("1")) {
theKey = hexToBytes("0101010101010101");theMsg = hexToBytes("8000000000000000");
theExp = hexToBytes("95F8A5E5DD31D900");
} else if (test.equals("2")) {theKey = hexToBytes("38627974656B6579"); // "8bytekey"
theMsg = hexToBytes("6D6573736167652E"); // "message."
theExp =hexToBytes("7CF45E129445D451");
} else {
System.out.println("Usage:");
System.out.println("java JceSunDesTest 1/2");Return;
}
KeySpec ks = new DESKeySpec(theKey);
SecretKeyFactory kf= SecretKeyFactory.getInstance("DES");
SecretKey ky = kf.generateSecret(ks);
Cipher cf = Cipher.getInstance("DES/ECB/NoPadding");cf.init(Cipher.ENCRYPT_MODE,ky);
byte[] theCph = cf.doFinal(theMsg);
System.out.println("Key : "+bytesToHex(theKey));...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Algoritmo Des
  • Algoritmo Des
  • Algoritmo Des
  • Algoritmo des
  • Algoritmo de cifrado de datos DES
  • Informe algoritmo des
  • Descripcion algoritmo de cifrado des
  • Deseado

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS