File: github-issue7.t

package info (click to toggle)
libcrypt-cbc-perl 3.07-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 364 kB
  • sloc: perl: 2,074; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 827 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use strict;
use warnings;
use Test::More;
use Crypt::CBC;

eval "use Crypt::Blowfish()";
if ($@) {
    print "1..0 # Skipped: Crypt::Blowfish not installed\n";
    exit;
}

# small script for Blowfish encryption and decryption

# The key for the blowfish encoding/decoding below
my $privateString = '123456789012345678901234567890123456789012';

my $teststring = "Testtext";

my $key = pack('H*', $privateString);

my $params = {
                'key' => $key,
                'cipher' => 'Blowfish',
                'header' => 'randomiv',
                'nodeprecate' => 1
            };

my $cipher = Crypt::CBC->new($params);
my $encoded = $cipher->encrypt_hex($teststring);

my $decoded = $cipher->decrypt_hex($encoded);

ok($teststring eq $decoded, "Properly decoded Blowfish with header => randomiv");

done_testing();