Die Verschlüsselung von Strings funktioniert, die Verschlüsselung des Array-Typs byte [] funktioniert nicht

Ich benutze die folgendenVERKNÜPFUNG für die Verschlüsselung und versuchte es mit Strings und es hat funktioniert. Da es sich jedoch um Bilder handelt, musste der Ver- / Entschlüsselungsprozess für Byte-Arrays durchgeführt werden. Deshalb habe ich den Code in diesem Link folgendermaßen geändert:

<code>public class AESencrp {

    private static final String ALGO = "AES";
    private static final byte[] keyValue = 
    new byte[] { 'T', 'h', 'e', 'B', 'e', 's', 't',
'S', 'e', 'c', 'r','e', 't', 'K', 'e', 'y' };

    public static byte[] encrypt(byte[] Data) throws Exception {
        Key key = generateKey();
        Cipher c = Cipher.getInstance(ALGO);
        c.init(Cipher.ENCRYPT_MODE, key);
        byte[] encVal = c.doFinal(Data);
        //String encryptedValue = new BASE64Encoder().encode(encVal);
        return encVal;
    }

    public static byte[] decrypt(byte[] encryptedData) throws Exception {
        Key key = generateKey();
        Cipher c = Cipher.getInstance(ALGO);
        c.init(Cipher.DECRYPT_MODE, key);

        byte[] decValue = c.doFinal(encryptedData);
        return decValue;
    }

    private static Key generateKey() throws Exception {
        Key key = new SecretKeySpec(keyValue, ALGO);
        return key;
    }
</code>

und die Checkerklasse ist:

<code>public class Checker {

    public static void main(String[] args) throws Exception {

        byte[] array = new byte[]{127,-128,0};
        byte[] arrayEnc = AESencrp.encrypt(array);
        byte[] arrayDec = AESencrp.decrypt(arrayEnc);

        System.out.println("Plain Text : " + array);
        System.out.println("Encrypted Text : " + arrayEnc);
        System.out.println("Decrypted Text : " + arrayDec);
    }
}
</code>

Meine Ausgabe ist jedoch:

<code>Plain Text : [B@1b10d42
Encrypted Text : [B@dd87b2
Decrypted Text : [B@1f7d134
</code>

Der entschlüsselte Text ist also nicht derselbe wie normaler Text. Wie kann ich dieses Problem beheben, wenn ich weiß, dass ich das Beispiel im ursprünglichen Link ausprobiert habe und es mit Strings funktioniert hat?

Antworten auf die Frage(3)

Ihre Antwort auf die Frage