James’ Pad: Java Triple DES example
liegt wohl näher dran, da ist auch von IvParameterSpec die Rede,
wieso braucht das aber auch beim Entschlüsseln den IvParameterSpec übergeben?
jetzt wären gute allgemeine Kenntnisse angebracht, wie funktioniert das Entschlüsseln?
Block cipher mode of operation - Wikipedia, the free encyclopedia
ah, muss am Ende auch noch wieder geXORt werden oder so,
mit dieser Hoffnung habe ich mich nochmal rangewagt und bin tatsächlich zu etwas gekommen,
im Zuge des Erfolgs und Selbstlobs poste ich mal ein wenig an Halblösung 
{
private static final String PLAIN_TEXT = "Hochschule Ostwestfalen-Lippe";
public static void main(String args[])
throws Exception
{
String algorithm = "DESede";
String transformation = "DESede/CBC/PKCS5Padding";
byte[] keyValue = new byte[]
{1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xe, 0, 1, 2, 3, 4, 5, 6, 7, 8};
DESedeKeySpec keySpec = new DESedeKeySpec(keyValue);
SecretKey key = SecretKeyFactory.getInstance(algorithm).generateSecret(keySpec);
IvParameterSpec iv = new IvParameterSpec(new byte[]
{0, 0, 0, 0, 0, 0, 0, 0});
Cipher encrypter = Cipher.getInstance(transformation);
encrypter.init(Cipher.ENCRYPT_MODE, key, iv);
byte[] input = PLAIN_TEXT.getBytes("UTF-8");
System.out.println("in : " + input.length + " - " + Arrays.toString(input));
byte[] enc = encrypter.doFinal(input);
System.out.println("enc1: " + enc.length + " - " + Arrays.toString(enc));
enc = new byte[]
{51, -116, 97, -126, -62, -46, -13, -80, 15, -107, -41, -77, 19, 50, -103, 72, 72, -120, -18, 80, -101, 104, 99, -4,
124, 25, 6, -50, 8, 3, -47, -1};
System.out.println("enc2: " + enc.length + " - " + Arrays.toString(enc));
Cipher decrypter = Cipher.getInstance(transformation);
decrypter.init(Cipher.DECRYPT_MODE, key, iv);
byte[] decrypted = decrypter.doFinal(enc);
System.out.println("de : " + decrypted.length + " - " + Arrays.toString(decrypted) + "
" + new String(decrypted, "UTF8"));
}
}
Ausgabe:
in : 29 - [72, 111, 99, 104, 115, 99, 104, 117, 108, 101, 32, 79, 115, 116, 119, 101, 115, 116, 102, 97, 108, 101, 110, 45, 76, 105, 112, 112, 101]
enc1: 32 - [-69, 108, -27, -70, -71, -11, 13, 49, -113, 11, 108, -33, -88, 56, 113, 118, 38, -102, 0, 29, -46, 112, 102, -128, -119, -25, -43, -62, 12, 126, 25, 109]
enc2: 32 - [51, -116, 97, -126, -62, -46, -13, -80, 15, -107, -41, -77, 19, 50, -103, 72, 72, -120, -18, 80, -101, 104, 99, -4, 124, 25, 6, -50, 8, 3, -47, -1]
de : 29 - [-126, -111, 98, 121, 98, 115, -57, -117, 108, 101, 32, 79, 115, 116, 119, 101, 115, 116, 102, 97, 108, 101, 110, 45, 76, 105, 112, 112, 101]
��bybsNjle Ostwestfalen-Lippe
die ersten 8 Bit sind noch falsch, weil der Initialisierungsvektor 0,0,0,0,0,0,0,0 falsch ist
wenn von hier aus alleine weiter, dann zumindest ein wenig auch alleine geschafft…