Código:
Necesito saber como encripta o desencripta esto las contraseñas que transforma "123456" en "sCS61OvmlQo=".// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: packimports(5) braces fieldsfirst noctor nonlb space lnc // Source File Name: DesEncrypter.java package prueba; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; import javax.crypto.*; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.PBEParameterSpec; import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; public class DesEncrypter { Cipher ecipher; Cipher dcipher; byte salt[] = { /* 27*/ -87, -101, -56, 50, 86, 53, -29, 3 }; int iterationCount; DesEncrypter(String passPhrase) { /* 33*/ iterationCount = 19; /* 38*/ try { /* 38*/ java.security.spec.KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount); /* 39*/ SecretKey key = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(keySpec); /* 41*/ ecipher = Cipher.getInstance(key.getAlgorithm()); /* 42*/ dcipher = Cipher.getInstance(key.getAlgorithm()); /* 45*/ java.security.spec.AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount); /* 48*/ ecipher.init(1, key, paramSpec); /* 49*/ dcipher.init(2, key, paramSpec); } /* 50*/ catch (InvalidAlgorithmParameterException e) { } /* 51*/ catch (InvalidKeySpecException e) { } /* 52*/ catch (NoSuchPaddingException e) { } /* 53*/ catch (NoSuchAlgorithmException e) { } /* 54*/ catch (InvalidKeyException e) { } } public String encrypt(String str) { byte enc[]; /* 61*/ byte utf8[] = str.getBytes("UTF8"); /* 64*/ enc = ecipher.doFinal(utf8); /* 67*/ return (new BASE64Encoder()).encode(enc); BadPaddingException e; /* 68*/ e; /* 72*/ break MISSING_BLOCK_LABEL_41; /* 69*/ e; /* 72*/ break MISSING_BLOCK_LABEL_41; /* 70*/ e; /* 72*/ break MISSING_BLOCK_LABEL_41; /* 71*/ e; /* 73*/ return null; } public String decrypt(String str) { byte utf8[]; /* 79*/ byte dec[] = (new BASE64Decoder()).decodeBuffer(str); /* 82*/ utf8 = dcipher.doFinal(dec); /* 85*/ return new String(utf8, "UTF8"); BadPaddingException e; /* 86*/ e; /* 90*/ break MISSING_BLOCK_LABEL_45; /* 87*/ e; /* 90*/ break MISSING_BLOCK_LABEL_45; /* 88*/ e; /* 90*/ break MISSING_BLOCK_LABEL_45; /* 89*/ e; /* 91*/ return null; } }
Gracias a todos por su ayuda.