Recently I've been working on a project that need to do PGP encrypt/decrypt. The best solution that I found is here. However the downside is the data need to be written to a file. I've modified the file so that encrypt/decrypt can be done on buffered streams. Below is how I do it.