Table of contents
Pretty Curved Privacy Version 0.1.5
Finally I can release version 0.1.5 of PCP. It's now really portable, it runs on AIX/power-pc (big-endian), FreeBSD, Linux and Windows (Cygwin). There's also now a C++ API and I fixed lots of bugs. Read the CHANGELOG for details.
PDF Seiten extrahieren und neu anordnen
Gestern hatte ich folgendes Problem: ich habe ein 4-seitiges Dokument eingescannt und der Scanner hat das PDF File falsch herum ausgespuckt, d.h. es fing mit Seite 4 an und hörte mit Seite 1 auf. Ich hätte es neu scannen können, aber dafür war es zu spät (ich war schon daheim). Was tun?
Nach ein wenig Googelei habe ich pdfjam gefunden. Es war gleich installiert, Latex hatte ich eh schon drauf, aber: es crashte mit meinem PDF File (Segmentation Fault). Nicht pdfjam crashte, sondern pdftex. Ich stand also erheblich auf dem Schlauch. Irgendwann fand ich heraus, dass man das gleiche auch mit Ghostscript tun kann und das Ergebnis wird sogar besser als das von pdfjam (weil Ghostscript die PDF Seiten nicht verändert).
Da die Commandline von Ghostscript nicht der Burner ist und ich das wie üblich gerne flexibel hätte, habe ich kurzerhand ein Wrapperscript geschrieben: pdfjamgs. Das ist im Prinzip ein Ersatz für pdfjam, nur mit Ghostscript als Backend und es unterstützt auch nicht alle Features von pdfjam. Zumindest einzelne Seiten aus einem oder mehreren Dokumenten kann man aber extrahieren und in ein neues PDF schreiben.
So sieht das zum Beispiel aus:
% pdfjamgs -i source.pdf:3,4,7-9 -o destination.pdf
Ich denke, das muss man nicht extra erklären. Und natürlich kann man -i mehrmals angeben.
Foto des Tages
Status C++ API for Pretty Curved Privacy
While I'm waiting for Frank to fix the AIX libsodium issue I thought it would be a good idea to start with a C++ API for Pretty Curved Privacy. And I've to admit, that it is really fun to do that. Working with the C++ API makes the whole thing a LOT easier. Here's an example of how to generate some keys and encrypt some data:
#include <pcp++.h> #include <string> #include <iostream>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; }
Now, that's easy, isn't it? At least I like it. The API is not ready though, signing and derived keys are not done yet. More example code can be seen in the C++ unittest.