📄 encrypt.t
字号:
ok 36, my $db = new BerkeleyDB::Hash -Filename => $Dfile, -Flags => DB_CREATE, -Encrypt => {Password => "beta", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; # create some data my %data = ( "red" => 2, "green" => "house", "blue" => "sea", ) ; my $ret = 0 ; while (($k, $v) = each %data) { $ret += $db->db_put($k, $v) ; } ok 37, $ret == 0 ; # check there are three records ok 38, countRecords($db) == 3 ; undef $db; # attempt to open a database without specifying encryption ok 39, ! new BerkeleyDB::Hash -Filename => $Dfile, -Flags => DB_CREATE ; # try opening with the wrong password ok 40, ! new BerkeleyDB::Hash -Filename => $Dfile, -Filename => $Dfile, -Encrypt => {Password => "def", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; # read the encrypted data ok 41, my $db1 = new BerkeleyDB::Hash -Filename => $Dfile, -Filename => $Dfile, -Encrypt => {Password => "beta", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; $v = ''; ok 42, ! $db1->db_get("red", $v) ; ok 43, $v eq $data{"red"}; # check there are three records ok 44, countRecords($db1) == 3 ; undef $db1;}{ # new BerkeleyDB::Btree -Encrypt => my $Dfile = "abcd.enc"; my $lex = new LexFile $Dfile ; my %hash ; my ($k, $v) ; ok 45, my $db = new BerkeleyDB::Btree -Filename => $Dfile, -Flags => DB_CREATE, -Encrypt => {Password => "beta", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; # create some data my %data = ( "red" => 2, "green" => "house", "blue" => "sea", ) ; my $ret = 0 ; while (($k, $v) = each %data) { $ret += $db->db_put($k, $v) ; } ok 46, $ret == 0 ; # check there are three records ok 47, countRecords($db) == 3 ; undef $db; # attempt to open a database without specifying encryption ok 48, ! new BerkeleyDB::Btree -Filename => $Dfile, -Flags => DB_CREATE ; # try opening with the wrong password ok 49, ! new BerkeleyDB::Btree -Filename => $Dfile, -Filename => $Dfile, -Encrypt => {Password => "def", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; # read the encrypted data ok 50, my $db1 = new BerkeleyDB::Btree -Filename => $Dfile, -Filename => $Dfile, -Encrypt => {Password => "beta", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; $v = ''; ok 51, ! $db1->db_get("red", $v) ; ok 52, $v eq $data{"red"}; # check there are three records ok 53, countRecords($db1) == 3 ; undef $db1;}{ # new BerkeleyDB::Queue -Encrypt => my $Dfile = "abcd.enc"; my $lex = new LexFile $Dfile ; my %hash ; my ($k, $v) ; ok 54, my $db = new BerkeleyDB::Queue -Filename => $Dfile, -Len => 5, -Pad => "x", -Flags => DB_CREATE, -Encrypt => {Password => "beta", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; # create some data my %data = ( 1 => 2, 2 => "house", 3 => "sea", ) ; my $ret = 0 ; while (($k, $v) = each %data) { $ret += $db->db_put($k, $v) ; } ok 55, $ret == 0 ; # check there are three records ok 56, countRecords($db) == 3 ; undef $db; # attempt to open a database without specifying encryption ok 57, ! new BerkeleyDB::Queue -Filename => $Dfile, -Len => 5, -Pad => "x", -Flags => DB_CREATE ; # try opening with the wrong password ok 58, ! new BerkeleyDB::Queue -Filename => $Dfile, -Len => 5, -Pad => "x", -Encrypt => {Password => "def", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; # read the encrypted data ok 59, my $db1 = new BerkeleyDB::Queue -Filename => $Dfile, -Len => 5, -Pad => "x", -Encrypt => {Password => "beta", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; $v = ''; ok 60, ! $db1->db_get(3, $v) ; ok 61, $v eq fillout($data{3}, 5, 'x'); # check there are three records ok 62, countRecords($db1) == 3 ; undef $db1;}{ # new BerkeleyDB::Recno -Encrypt => my $Dfile = "abcd.enc"; my $lex = new LexFile $Dfile ; my %hash ; my ($k, $v) ; ok 63, my $db = new BerkeleyDB::Recno -Filename => $Dfile, -Flags => DB_CREATE, -Encrypt => {Password => "beta", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; # create some data my %data = ( 1 => 2, 2 => "house", 3 => "sea", ) ; my $ret = 0 ; while (($k, $v) = each %data) { $ret += $db->db_put($k, $v) ; } ok 64, $ret == 0 ; # check there are three records ok 65, countRecords($db) == 3 ; undef $db; # attempt to open a database without specifying encryption ok 66, ! new BerkeleyDB::Recno -Filename => $Dfile, -Flags => DB_CREATE ; # try opening with the wrong password ok 67, ! new BerkeleyDB::Recno -Filename => $Dfile, -Filename => $Dfile, -Encrypt => {Password => "def", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; # read the encrypted data ok 68, my $db1 = new BerkeleyDB::Recno -Filename => $Dfile, -Filename => $Dfile, -Encrypt => {Password => "beta", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; $v = ''; ok 69, ! $db1->db_get(3, $v) ; ok 70, $v eq $data{3}; # check there are three records ok 71, countRecords($db1) == 3 ; undef $db1;}{ # new BerkeleyDB::Unknown -Encrypt => my $Dfile = "abcd.enc"; my $lex = new LexFile $Dfile ; my %hash ; my ($k, $v) ; ok 72, my $db = new BerkeleyDB::Hash -Filename => $Dfile, -Flags => DB_CREATE, -Encrypt => {Password => "beta", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; # create some data my %data = ( "red" => 2, "green" => "house", "blue" => "sea", ) ; my $ret = 0 ; while (($k, $v) = each %data) { $ret += $db->db_put($k, $v) ; } ok 73, $ret == 0 ; # check there are three records ok 74, countRecords($db) == 3 ; undef $db; # attempt to open a database without specifying encryption ok 75, ! new BerkeleyDB::Unknown -Filename => $Dfile, -Flags => DB_CREATE ; # try opening with the wrong password ok 76, ! new BerkeleyDB::Unknown -Filename => $Dfile, -Filename => $Dfile, -Encrypt => {Password => "def", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; # read the encrypted data ok 77, my $db1 = new BerkeleyDB::Unknown -Filename => $Dfile, -Filename => $Dfile, -Encrypt => {Password => "beta", Flags => DB_ENCRYPT_AES }, -Property => DB_ENCRYPT ; $v = ''; ok 78, ! $db1->db_get("red", $v) ; ok 79, $v eq $data{"red"}; # check there are three records ok 80, countRecords($db1) == 3 ; undef $db1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -