Created
November 12, 2019 11:30
-
-
Save j1n3l0/1fe5fc22ad1457b2f03db3627eaef8b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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