
I want to encrypt data use two layer cipher as follow,but it seems not work, why and how, thanksï¼?
encrypt partï¼? Cipher cf1 = Cipher.getInstance(ciphAlg1); cf1.init(Cipher.ENCRYPT_MODE, key1, paramSpec); Cipher cf2 = Cipher.getInstance(ciphAlg2); cf2.init(Cipher.ENCRYPT_MODE, key2, paramSpec2);
FileInputStream fis = new FileInputStream(inputFile); FileOutputStream fos = new FileOutputStream(outputFile); CipherOutputStream cos1 = new CipherOutputStream(fos, cf1); CipherOutputStream cos2 = new CipherOutputStream(cos1, cf2);
decrypt partï¼? Cipher cf1 = Cipher.getInstance(ciphAlg1); cf1.init(Cipher.DECRYPT_MODE, key1, paramSpec); Cipher cf2 = Cipher.getInstance(ciphAlg2); cf2.init(Cipher.DECRYPT_MODE, key2, paramSpec2);
FileInputStream fis = new FileInputStream(inputFile); FileOutputStream fos = new FileOutputStream(outputFile);
CipherOutputStream cos1 = new CipherOutputStream(fos, cf2); CipherOutputStream cos2 = new CipherOutputStream(cos1, cf1);
One layer work well, but the double...
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.