It looks like you're new here. If you want to get involved, click one of these buttons!
[/spoiler]Copyright 2011 Deque at http://haxme.org/, http://www.iexploit.org/, http://poisonhack.info/. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY Deque at http://haxme.org/, http://www.iexploit.org/, http://poisonhack.info/ ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Deque at http://haxme.org/, http://www.iexploit.org/, http://poisonhack.info/ OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the
authors and should not be interpreted as representing official policies, either expressed
or implied, of Deque at http://haxme.org/, http://www.iexploit.org/, http://poisonhack.info/.
it look like a nice project i can understand that you used AES and DES algorithm to encrypt data but i don't know the others algorithms
# Triple DES
# ARCFOUR
# Blowfish
# RC2
# RC4
# Rijndael
# Shift Cipher
May be if you can give us the idea to how decrypt !
may be I can help
import java.security.InvalidKeyException;
import java.security.InvalidParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.security.Security;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
public class EnDecryption {
private final Cipher cipher;
private final SecretKeySpec spec;
public static void main(String[] args) throws Exception {
printAvailableServices(\"Cipher\");
printAvailableServices(\"KeyGenerator\");
String keyAlgorithm = args.length <= 0 ? \"AES\" : args[0];
String transformation = args.length <= 1 ? \"AES\" : args[1];
try {
int keysize = Integer.parseInt(args.length <= 2 ? \"128\" : args[2]);
System.out.println(\"Program instantiated with \" + keyAlgorithm
+ \" as key generating algorithm, \" + transformation
+ \" as transformation algorithm and \" + keysize
+ \" as key size.\n\");
Scanner scanner = new Scanner(System.in);
System.out.println(\"Your message: \");
String message = scanner.nextLine();
EnDecryption d = new EnDecryption(keysize, keyAlgorithm,
transformation);
byte[] encryptedMsg = d.encrypt(message);
byte[] decryptedMsg = d.decrypt(encryptedMsg);
System.out.println(\"\nencrypted message: \"
+ convertToHex(encryptedMsg));
System.out.println(\"decrypted message as Hex: \"
+ convertToHex(decryptedMsg));
System.out.println(\"decrypted message as String: \"
+ new String(decryptedMsg));
} catch (NoSuchAlgorithmException e) {
System.err.println(\"wrong algorithm input\n\" + e.getMessage());
} catch (NoSuchPaddingException e) {
System.err.println(\"wrong padding input\n\" + e.getMessage());
} catch (NumberFormatException e) {
System.err.println(\"third argument for key size is not a number\n\"
+ e.getMessage());
} catch (InvalidParameterException e) {
System.err.println(e.getMessage());
} catch (InvalidKeyException e) {
System.err.println(e.getMessage());
}
}
public EnDecryption(int keysize, String algorithm, String transformation)
throws NoSuchAlgorithmException, NoSuchPaddingException {
KeyGenerator keygen = KeyGenerator.getInstance(algorithm);
keygen.init(keysize);
SecretKey skey = keygen.generateKey();
spec = new SecretKeySpec(skey.getEncoded(), algorithm);
cipher = Cipher.getInstance(transformation);
}
private byte[] decrypt(byte[] msg) throws InvalidKeyException,
IllegalBlockSizeException, BadPaddingException {
cipher.init(Cipher.DECRYPT_MODE, spec);
return cipher.doFinal(msg);
}
private byte[] encrypt(String msg) throws InvalidKeyException,
IllegalBlockSizeException, BadPaddingException {
cipher.init(Cipher.ENCRYPT_MODE, spec);
return cipher.doFinal(msg.getBytes());
}
public static String convertToHex(byte array[]) {
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < array.length; i++) {
if ((array[i] & 0xff) < 0x10)
buffer.append(\"0\");
buffer.append(Integer.toString(array[i] & 0xff, 16));
}
return buffer.toString();
}
public static Set<String> getCryptImplementations(String serviceType) {
Set<String> result = new HashSet<String>();
for (Provider provider : Security.getProviders()) {
Set<Object> keys = provider.keySet();
for (Object k : keys) {
String key = ((String) k).split(\" \")[0];
if (key.startsWith(serviceType + \".\")) {
result.add(key.substring(serviceType.length() + 1));
} else if (key.startsWith(\"Alg.Alias.\" + serviceType + \".\")) {
result.add(key.substring(serviceType.length() + 11));
}
}
}
return result;
}
public static void printAvailableServices(String service) {
boolean first = true;
System.out.println(\"List of available \" + service + \"s\");
for (String s : getCryptImplementations(service)) {
System.out.print(first ? s : \", \" + s);
first = false;
}
System.out.println();
System.out.println();
}
}