Stack Exchange
(Triple DES) DESede/CBC/PKCS5Padding Encryption and decryption in Qt Creator
I want to use JAVA encryption and decryption logic in qt creator code i tried and search lot of stuff but success for "DES/CBC" Encryption and Decryption Logic but not useful for me Because JAVA code is in "DESede/CBC/PKCS5Padding" Triple DES logic.
JAVA CODE is as follows:
public static String initializationVector = "abhijeet";   
public static String key="XB13347FE570DC4FFB13647F";    

public String encryptText(String plainText) throws Exception {
    // ---- Use specified 3DES key and IV from other source --------------
    byte[] plaintext = plainText.getBytes();
    byte[] tdesKeyData = Config.key.getBytes();
    // byte[] myIV = initializationVector.getBytes();
    Cipher c3des = Cipher.getInstance("DESede/CBC/PKCS5Padding");
    SecretKeySpec myKey = new SecretKeySpec(tdesKeyData, "DESede");
    IvParameterSpec ivspec = new IvParameterSpec(Config.initializationVector.getBytes());
    c3des.init(Cipher.ENCRYPT_MODE, myKey, ivspec);
    byte[] cipherText = c3des.doFinal(plaintext);
    return new BASE64Encoder().encode(cipherText);
}

public static String decryptText(String cipherText) throws Exception {
    byte[] encData = new BASE64Decoder().decodeBuffer(cipherText);
    Cipher decipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
    byte[] tdesKeyData = Config.key.getBytes();
    SecretKeySpec myKey = new SecretKeySpec(tdesKeyData, "DESede");
    IvParameterSpec ivspec = new IvParameterSpec(Config.initializationVector.getBytes());
    decipher.init(Cipher.DECRYPT_MODE, myKey, ivspec);
    byte[] plainText = decipher.doFinal(encData);
    return new String(plainText);
}

Example :
Input string  -  "Hello"
After Encryption Output string - "c13FZpr4odg="
Please Help for the same as i stuck here

fyi: DES has been broken; Tripple-DES is obsoleted.  Use AES.

Already project is made in Triple DES so i want that in Triple DES logic only. I am ready to use AES but project requirement is Triple DES.

Atleast give me syntax for 3DES Encryption decryption as i have for "DES/CBS" Encryption code is as follows:                                                   //     encrypt
Botan::Pipe
pipe(Botan::get_cipher("DES/CBC",key10,iv,Botan::ENCRYPTION),new
Botan::Base64_Encoder);
pipe.process_msg(ui->inputTextEdit->toPlainText().toStdString());
std::string CipherText = pipe.read_all_as_string();
ui->encrypt_textEdit->setText(QString::fromStdString(CipherText));

Have you checked this question? https://stackoverflow.com/questions/20227/how-do-i-use-3des-encryption-decryption-in-java
