// There are two participants in the session, A and B
// Each has their own DHContext. A creates their context and
// sends the request key parameters to B. B uses those parameters
// to create their context, the returns it's public key
// back to A.
DHContext context_a = new DHContext();
DHContext context_b = new DHContext(context_a.getRequestString());
context_a.setPublicKey(context_b.getResponseString());
// Prepare the encryption options
Encryption enc = absec.getEncryption();
// Encrypt the document using A's DHContext
EncryptionOptions options = context_a.getEncryptionOptions(enc);
Document enc_doc = enc.encrypt(entry.getDocument(), options);
enc_doc.writeTo(System.out);
System.out.println("\n\n");
// Decrypt the document using B's DHContext
options = context_b.getEncryptionOptions(enc);
Document<Entry> entry_doc = enc.decrypt(enc_doc, options);
entry_doc.writeTo(System.out);
}