import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
public class Main {
private final static char[] ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
private static int[] toInt = new int[128];
static {
for(int i=0; i< ALPHABET.length; i++){
toInt[ALPHABET[i]]= i;
}
}
public static byte[] base64Decode
(String s
){ int delta = s.endsWith( "==" ) ? 2 : s.endsWith( "=" ) ? 1 : 0;
byte[] buffer = new byte[s.length()*3/4 - delta];
int mask = 0xFF;
int index = 0;
for(int i=0; i< s.length(); i+=4){
int c0 = toInt[s.charAt( i )];
int c1 = toInt[s.charAt( i + 1)];
buffer[index++]= (byte)(((c0 << 2) | (c1 >> 4)) & mask);
if(index >= buffer.length){
return buffer;
}
int c2 = toInt[s.charAt( i + 2)];
buffer[index++]= (byte)(((c1 << 4) | (c2 >> 2)) & mask);
if(index >= buffer.length){
return buffer;
}
int c3 = toInt[s.charAt( i + 3 )];
buffer[index++]= (byte)(((c2 << 6) | c3) & mask);
}
return buffer;
}
private static final String password
= "KYANINYLhijklmnopqrstuvwx"; private static SecretKey SECRETE_KEY;
private static Cipher DES_CIPHER;
private static final String ALGORITHM
= "DESede";
static {
try {
byte key[] = password.getBytes();
DESedeKeySpec desKeySpec = new DESedeKeySpec(key);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
SECRETE_KEY = keyFactory.generateSecret(desKeySpec);
DES_CIPHER = Cipher.getInstance(ALGORITHM + "/ECB/PKCS5Padding");
System.
out.
println("Exception occurred while creating secret key" + t
); }
}
private static byte[] decryptByDES
(byte[] bytes
) throws Exception{ DES_CIPHER.init(Cipher.DECRYPT_MODE, SECRETE_KEY);
return DES_CIPHER.doFinal(bytes);
}
return new String(decryptByDES
(base64Decode
(s
))); }
public static void main
(String[] args
) { if (args.length < 1)
try {
System.
out.
println(getDecryptedString
("lnv+xReP3ozuelULwx4/hg==")); }
}
}