Salve.
Se ho un testo cifrato in des e lo stesso testo non cifrato, posso scoprire la chiave di cifratura?
Grazie,
Matteo
Moderatore: Staff
1011010 1100101 1110010 1101111 - 0100000 - 1010101 1101110 1101111

1011010 1100101 1110010 1101111 - 0100000 - 1010101 1101110 1101111

$ java DesEncrypt "ciao a tutti"
Orginal string: ciao a tutti
Crypted string:xxxxxxxxxxxxxx==1011010 1100101 1110010 1101111 - 0100000 - 1010101 1101110 1101111
.
. Dacci un'occhiata.
spina ha scritto:Ma dai sorgenti del programma Java non riesci a capire che chiave usa? Inoltre è un po' bizzarro voler sapere la chiave quando sai già il testo in chiaro.
1011010 1100101 1110010 1101111 - 0100000 - 1010101 1101110 1101111

ocman ha scritto:ciao
1.
spina ha detto bene. se è veramente un oggetto standalone java che si appoggia al massimo sulla jdk per qualche libreria allora puoi sempre ottenere il sorgente.
http://java.sun.com/developer/Books/jav ... npack.html
molto probabilmente al suo interno non farà altro che passare la chiave e il parametro in input alle funzioni descritte qui sotto
http://download.oracle.com/javase/6/doc ... tml#Cipher





1011010 1100101 1110010 1101111 - 0100000 - 1010101 1101110 1101111
class Encrypt
{
Cipher ecipher;
byte[] salt = { 1, 2, 3, 4, 5, 6, 7, 8 }; // 8 numeri
int iterationCount = 10; // un numero
public Encrypt() {
try {
String temp = "una_stringa";
KeySpec keySpec = new PBEKeySpec(temp.toCharArray(), this.salt, this.iterationCount);
SecretKey key = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(keySpec);
this.ecipher = Cipher.getInstance(key.getAlgorithm());
AlgorithmParameterSpec paramSpec = new PBEParameterSpec(this.salt, this.iterationCount);
this.ecipher.init(1, key, paramSpec);
} catch (Exception e) { }
}
public String encrypt(String aString) {
try {
byte[] utf8 = aString.getBytes("UTF8");
byte[] enc = this.ecipher.doFinal(utf8);
return new BASE64Encoder().encode(enc);
} catch (Exception e) { }
return null;
}
}1011010 1100101 1110010 1101111 - 0100000 - 1010101 1101110 1101111
Visitano il forum: Nessuno e 0 ospiti