Skip to content

Instantly share code, notes, and snippets.

@j1n3l0
Created November 12, 2019 11:30
Show Gist options
  • Save j1n3l0/1fe5fc22ad1457b2f03db3627eaef8b1 to your computer and use it in GitHub Desktop.
Save j1n3l0/1fe5fc22ad1457b2f03db3627eaef8b1 to your computer and use it in GitHub Desktop.
use Test2::V0 -target => 'Crypt::CBC';
subtest 'Crypt::CBC' => sub {
my $a = Crypt::CBC->new(qw< -key A -cipher Blowfish >);
my $b = Crypt::CBC->new(qw< -key B -cipher Blowfish >);
my $s = 'Hello, World!';
is(
$a->decrypt( $a->encrypt($s) ),
$s,
'should encrypt[A] + decrypt[A] to the original value',
);
is(
$b->decrypt( $b->encrypt($s) ),
$s,
'should encrypt[B] + decrypt[B] to the original value',
);
isnt(
$a->decrypt( $b->encrypt($s) ),
$s,
'should fail when cipher secret is different - encrypt[B] + decrypt[A]',
);
};
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment