Crypt::OTR is a Perl wrapper around libotr - see http://www.cypherpunks.ca/otr/README-libotr-3.2.0.txt
This module is experimental and unfinished, not yet recommended for production or important systems.
SYNOPSIS
use Crypt::OTR;
# call near the beginning of your program
Crypt::OTR->init;
# create OTR object, set up callbacks
my $otr = new Crypt::OTR(
account_name => "alice", # name of account associated with this keypair
protocol_name => "my_protocol_name", # e.g. 'AIM'
max_message_size => 1024, # how much to fragment
);
$otr->set_callback('inject' => \&otr_inject);
$otr->set_callback('otr_message' => \&otr_system_message);
$otr->set_callback('verified' => \&otr_verified);
$otr->set_callback('unverified' => \&otr_unverified);
# create a context for user "bob"
$otr->establish("bob"); # calls otr_inject($account_name, $protocol, $dest_account, $message)
# send a message to bob
my $plaintext = "hello, bob! this is a message from alice";
if (my $ciphertext = $otr->encrypt("bob", $plaintext)) {
$my_app->send_message_to_user("bob", $ciphertext);
} else {
warn "Your message was not sent - no encrypted conversation is established\n";
}
# called from bob's end
if (my $plaintext = $otr->decrypt("alice", $ciphertext)) {
print "alice: $plaintext\n";
} else {
warn "We received an encrypted message from alice but were unable to decrypt it\n";
}
# done with chats
$otr->finish("bob");
# CALLBACKS
# called when OTR is ready to send a message after massaging it.
# this method should actually transmit $message to $dest_account
sub otr_inject {
my ($self, $account_name, $protocol, $dest_account, $message) = @_;
$my_app->send_message_to_user($dest_account, $message);
}
# called to display an OTR control message for a particular user or protocol
sub otr_system_message {
my ($self, $account_name, $protocol, $other_user, $otr_message) = @_;
warn "OTR says: $otr_message\n";
return 1;
}
# called when a verified conversation is established with $from_account
sub verified {
my ($self, $from_account) = @_;
print "Started verified conversation with $from_account\n";
}
# called when an unverified conversation is established with $from_account
sub unverified {
my ($self, $from_account) = @_;
print "Started unverified conversation with $from_account\n";
}
Product's homepage
Requirements:
· Perl