on 03-27-2012 5:46 AM
Hello, I'm using the Bouncycastle 1.46 API for encrypting payload. I'm able to encrypt the payload but am having difficulty in armoring (converting the encrypted text to ASCII) and subsequently convert the armored output stream to a Byte Array. I'm converting to byte array so that the module data can be updated with the encrypted & armored payload.
The code looks as follows:
//Define an armored output stream
OutputStream out = null;
ByteArrayOutputStream oBAOS = new ByteArrayOutputStream();
out = new ArmoredOutputStream(oBAOS);
//bOut is the ByteArrayOutputStream from the Encryptor (available after encryption)
byte[] bytes = bOut.toByteArray();
//cPk is the object of PGPEncryptedDataGenerator
OutputStream ByteOut = cPk.open(out, bytes.length);
ByteOut.write(bytes);
//Get the encrypted and armored payload from ByteOut OutputStream
payload.setContent(ByteOut.toByteArray());
inputModuleData.setPrincipalData(msg);
I'm unsure if what I've coded in the lines highlighted in bold is correct. If I execute the code as a bean or as a sample application, I'm not getting any error nor the desired result. Any input is appreciated!
Thanks!!
Never used Bouncycastle 1.46 API,
Have you tested your code in stand alone system(NWDS or eclipse)better to test then convert in to Adaptyer module,i hope the you have genarated EAR file with additional JAR files(used in your code).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am testing the code in Eclipse as a standalone application. The approach I've taken is available in the URL http://stackoverflow.com/questions/3939447/how-to-encrypt-a-string-stream-with-bouncycastle-pgp-with...
I'm having trouble in converting the encrypted ByteArrayOutputStream into ArmoredOutputStream (a part of Bouncycastle API and implements OutputStream) and subsequently convery the ArmoredOutputStream back to a Byte Array. This Byte Array will eventually have to be used to update inputModuleData object in the User Adapter Module
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.