/u is working
This commit is contained in:
parent
7dc08d0742
commit
f82196013f
26
II/Enc.pm
26
II/Enc.pm
@ -18,6 +18,24 @@ sub new {
|
|||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub decrypt {
|
||||||
|
my ( $self, $file ) = @_;
|
||||||
|
|
||||||
|
open my $fh, "<", $file or die "Cannot open file $file: $!\n";
|
||||||
|
my $message;
|
||||||
|
while (<$fh>) {
|
||||||
|
$message .= $_;
|
||||||
|
}
|
||||||
|
close $fh;
|
||||||
|
|
||||||
|
my @enc = split /:/, $message;
|
||||||
|
|
||||||
|
# Decrypt message
|
||||||
|
my $dec = `echo "$enc[1]" | base64 -d`;
|
||||||
|
|
||||||
|
return $dec;
|
||||||
|
}
|
||||||
|
|
||||||
sub encode {
|
sub encode {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
my $config = $self->{_config};
|
my $config = $self->{_config};
|
||||||
@ -26,10 +44,10 @@ sub encode {
|
|||||||
my $hash = II::Enc->new_hash();
|
my $hash = II::Enc->new_hash();
|
||||||
|
|
||||||
# Make base64 message
|
# Make base64 message
|
||||||
my $message = $data->{echo}."\n";
|
my $message = $data->{echo} . "\n";
|
||||||
$message .= $data->{to}."\n";
|
$message .= $data->{to} . "\n";
|
||||||
$message .= $data->{subg}."\n\n";
|
$message .= $data->{subg} . "\n\n";
|
||||||
$message .= '@repto:'.$data->{hash}."\n" if defined($data->{hash});
|
$message .= '@repto:' . $data->{hash} . "\n" if defined( $data->{hash} );
|
||||||
$message .= $data->{post};
|
$message .= $data->{post};
|
||||||
|
|
||||||
my $encoded = `echo "$message" | base64`;
|
my $encoded = `echo "$message" | base64`;
|
||||||
|
12
II/Get.pm
12
II/Get.pm
@ -2,6 +2,7 @@ package II::Get;
|
|||||||
use LWP::Simple;
|
use LWP::Simple;
|
||||||
|
|
||||||
use II::DB;
|
use II::DB;
|
||||||
|
use II::Enc;
|
||||||
|
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
@ -22,8 +23,8 @@ sub get_echo {
|
|||||||
|
|
||||||
my $db = II::DB->new();
|
my $db = II::DB->new();
|
||||||
|
|
||||||
my $echo_url = 'e/';
|
my $echo_url = 'u/e/';
|
||||||
my $msg_url = 'm/';
|
my $msg_url = 'u/m/';
|
||||||
|
|
||||||
my $msgs;
|
my $msgs;
|
||||||
foreach my $echo (@$echoareas) {
|
foreach my $echo (@$echoareas) {
|
||||||
@ -43,6 +44,7 @@ sub get_echo {
|
|||||||
or die "Cannot open file: $!\n";
|
or die "Cannot open file: $!\n";
|
||||||
while (<$echo_fh>) {
|
while (<$echo_fh>) {
|
||||||
chomp($_);
|
chomp($_);
|
||||||
|
if ($_ =~ /.{20}/) {
|
||||||
if ( !( -e "./msg/$_" ) ) {
|
if ( !( -e "./msg/$_" ) ) {
|
||||||
$msgs .= $_ . "\n";
|
$msgs .= $_ . "\n";
|
||||||
# @w_cmd = ( 'wget', '-O',
|
# @w_cmd = ( 'wget', '-O',
|
||||||
@ -51,6 +53,7 @@ sub get_echo {
|
|||||||
# system(@w_cmd) == 0 or die "Cannot download file: $!\n";
|
# system(@w_cmd) == 0 or die "Cannot download file: $!\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
close $echo_fh;
|
close $echo_fh;
|
||||||
|
|
||||||
# }
|
# }
|
||||||
@ -62,7 +65,10 @@ sub get_echo {
|
|||||||
my @msg_list = split /\n/, $msgs;
|
my @msg_list = split /\n/, $msgs;
|
||||||
while (<@msg_list>) {
|
while (<@msg_list>) {
|
||||||
my $mes_hash = $_;
|
my $mes_hash = $_;
|
||||||
open my $m, "<", "./msg/$mes_hash"
|
|
||||||
|
my $text = II::Enc->decrypt("./msg/$mes_hash");
|
||||||
|
|
||||||
|
open my $m, "<", \$text
|
||||||
or die "Cannot open message: $!\n";
|
or die "Cannot open message: $!\n";
|
||||||
|
|
||||||
my @mes;
|
my @mes;
|
||||||
|
Loading…
Reference in New Issue
Block a user