[foaf-protocols] WebID for signing RDF graphs
Toby Inkster
tai at g5n.co.uk
Wed Sep 22 23:20:11 CEST 2010
On Tue, 21 Sep 2010 23:59:18 +0100
Toby Inkster <tai at g5n.co.uk> wrote:
> This all seems to work quite nicely. Once I have got encryption and
> decryption working, I'll make a release.
As promised, I've just uploaded RDF-Crypt-0.001 to CPAN. It will take
a while to work its way through CPAN's pipes but should eventually end
up at:
http://search.cpan.org/dist/RDF-Crypt/
Encryption and decryption were a little trickier than I'd expected
because the RSA library I was using only supported them in their most
basic form: encrypting a string no longer than the key length. So I
needed to implement a block cipher myself.
It's pretty easy to encrypt a file and send it to someone with a WebID.
e.g.
###################################################################
use RDF::Crypt;
use RDF::TrineShortcuts;
# Create an Encrypter object
my $E = RDF::Crypt::Encrypter->new_from_webid(
'http://tobyinkster.co.uk/#i');
# Here's the data we want to send
my $model = rdf_parse('/home/tai/data/test.ttl', type=>'Turtle');
# Sending options, though the defaults are kinda usable
my $opts = {
from => 'tai at g5n.co.uk',
subject => 'Here it is!',
sendmail => { executable => '/usr/bin/msmtp' },
};
# Actually send the message. The encrypter takes care of
# encrypting the model using the public key found by dereferencing
# the WebID, figures out their e-mail address using foaf:mbox,
# formats the e-mail and sends it out.
my $mid = $E->send_model_by_email($model, $opts);
if (defined $mid)
{
print "Message sent with Message-ID $mid\n";
}
else
{
print "Sending failed.\n";
}
###################################################################
--
Toby A Inkster
<mailto:mail at tobyinkster.co.uk>
<http://tobyinkster.co.uk>
More information about the foaf-protocols
mailing list