daemon.de

Status C++ API for Pretty Curved Privacy

using namespace pcp; using namespace std;

int main() { try { /* generate 2 secret keys */ Key A = Key("a", "alicia", "alicia@local"); Key B = Key("b", "bobby", "bobby@local");

/* extract the public parts of them */ PubKey PA = A.get_public(); PubKey PB = B.get_public();

/* decrypt the secret keys */ A.decrypt("a"); B.decrypt("b");

/* create crypto objects (1st for the sender, 2nd for the recipient) */ Crypto A2B(A, PB); Crypto B2A(B, PA);

/* actually encrypt something (alicia to bobby) */ string cipher = A2B.encrypt("Hallo");

/* and decrypt it (bobby from alicia) */ ResultSet res = B2A.decrypt(cipher);

/* see if it worked as expected */ if(res.String == "Hallo") cout << "ok" << endl; else throw pcp::exception("wtf - decryption failed (uncatched as well)"); } catch (pcp::exception &E) { cerr << "Catched exception: " << E.what() << endl; } return 0; }

#Source