From: Himesh M. <hm...@hn...> - 2006-07-10 20:07:32
|
Hi, =20 I am trying to work my way through the examples to decrypt a file. Below = is the psedo code. =20 // Read the message file. FileInputStream fis =3D null; try { fis =3D new FileInputStream(fileName); } catch (FileNotFoundException e1) { logger.error("Unable the file to be decoded"); throw new PGPHelperException("Missing the message file" +=20 e1.getMessage()); } EncryptedMessage encMsg =3D null; =20 // Try to read message try { Collection msgs =3D this.mf.generateMessages(fis); encMsg =3D (EncryptedMessage)msgs.iterator().next(); } catch (Exception e) { System.out.println(e.getMessage()); }=20 =20 // Decode the message and return decoded message. try { PGPSignedMessageImpl decMsg =3D (PGPSignedMessageImpl) = encMsg.decrypt(this.key, // the key "passphrase".toCharArray()); =20 String decodedMessage =3D String(decMsg.getContents().getEncoded()); } catch (Exception e) { System.out.println(e.getMessage()); } When I look at the decodedString I always get some extra garbage = characters. For example: If my file had word -- "Test" and the file name = was "TestDocument.txt" =20 I get following output.=20 =AC=1Ab=10TestDocument.txt=FETest =20 =20 Can someone help me out to get rid of the extra characters ? =20 =20 - Himesh |