| 1 | package Crypt::Sodium::XS::shorthash; | ||
| 2 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 1 | ▶ | use Crypt::Sodium::XS; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use Exporter 'import'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 1 | _define_constants(); | |
| 9 | |||
| 10 | { | ||
| 11 | 1 | my @constant_bases = qw( | |
| 12 | BYTES | ||
| 13 | KEYBYTES | ||
| 14 | ); | ||
| 15 | |||
| 16 | 1 | my @bases = qw( | |
| 17 | keygen | ||
| 18 | ); | ||
| 19 | |||
| 20 | my $default = [ | ||
| 21 | "shorthash", | ||
| 22 | 1 | (map { "shorthash_$_" } @bases), | |
| 23 | 1 | (map { "shorthash_$_" } @constant_bases, "PRIMITIVE"), | |
| 24 | ]; | ||
| 25 | my $siphash24 = [ | ||
| 26 | "shorthash_siphash24", | ||
| 27 | 1 | (map { "shorthash_siphash24_$_" } @bases), | |
| 28 | 1 | (map { "shorthash_siphash24_$_" } @constant_bases), | |
| 29 | ]; | ||
| 30 | my $siphashx24 = [ | ||
| 31 | "shorthash_siphashx24", | ||
| 32 | 1 | (map { "shorthash_siphashx24_$_" } @bases), | |
| 33 | 1 | (map { "shorthash_siphashx24_$_" } @constant_bases), | |
| 34 | ]; | ||
| 35 | |||
| 36 | 1 | our %EXPORT_TAGS = ( | |
| 37 | all => [ @$default, @$siphash24, @$siphashx24 ], | ||
| 38 | default => $default, | ||
| 39 | siphash24 => $siphash24, | ||
| 40 | siphashx24 => $siphashx24, | ||
| 41 | ); | ||
| 42 | |||
| 43 | 1 | our @EXPORT_OK = @{$EXPORT_TAGS{all}}; | |
| 44 | } | ||
| 45 | |||
| 46 | package Crypt::Sodium::XS::OO::shorthash; | ||
| 47 | 1 | ▶ | use parent 'Crypt::Sodium::XS::OO::Base'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 48 | |||
| 49 | my %methods = ( | ||
| 50 | default => { | ||
| 51 | BYTES => \&Crypt::Sodium::XS::shorthash::shorthash_BYTES, | ||
| 52 | KEYBYTES => \&Crypt::Sodium::XS::shorthash::shorthash_KEYBYTES, | ||
| 53 | PRIMITIVE => \&Crypt::Sodium::XS::shorthash::shorthash_PRIMITIVE, | ||
| 54 | keygen => \&Crypt::Sodium::XS::shorthash::shorthash_keygen, | ||
| 55 | shorthash => \&Crypt::Sodium::XS::shorthash::shorthash, | ||
| 56 | }, | ||
| 57 | siphash24 => { | ||
| 58 | BYTES => \&Crypt::Sodium::XS::shorthash::shorthash_siphash24_BYTES, | ||
| 59 | KEYBYTES => \&Crypt::Sodium::XS::shorthash::shorthash_siphash24_KEYBYTES, | ||
| 60 | 0 | ▶ | PRIMITIVE => sub { 'siphash24' }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 61 | keygen => \&Crypt::Sodium::XS::shorthash::shorthash_siphash24_keygen, | ||
| 62 | shorthash => \&Crypt::Sodium::XS::shorthash::shorthash_siphash24, | ||
| 63 | }, | ||
| 64 | siphashx24 => { | ||
| 65 | BYTES => \&Crypt::Sodium::XS::shorthash::shorthash_siphashx24_BYTES, | ||
| 66 | KEYBYTES => \&Crypt::Sodium::XS::shorthash::shorthash_siphashx24_KEYBYTES, | ||
| 67 | 0 | ▶ | PRIMITIVE => sub { 'siphashx24' }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 68 | 1 | keygen => \&Crypt::Sodium::XS::shorthash::shorthash_siphashx24_keygen, | |
| 69 | shorthash => \&Crypt::Sodium::XS::shorthash::shorthash_siphashx24, | ||
| 70 | }, | ||
| 71 | ); | ||
| 72 | |||
| 73 | 4 | ▶ | sub Crypt::Sodium::XS::shorthash::primitives { keys %methods } |
|
Subroutine
primitives: called CC=1 SCAR=0.0
Pod
documented
| |||
| 74 | 1 | *primitives = \&Crypt::Sodium::XS::shorthash::primitives; | |
| 75 | |||
| 76 | 3 | ▶ | sub BYTES { my $self = shift; goto $methods{$self->{primitive}}->{BYTES}; } |
|
Subroutine
BYTES: called CC=1 SCAR=0.0
| |||
| 77 | 3 | ▶ | sub KEYBYTES { my $self = shift; goto $methods{$self->{primitive}}->{KEYBYTES}; } |
|
Subroutine
KEYBYTES: called CC=1 SCAR=0.0
| |||
| 78 | 0 | ▶ | sub PRIMITIVE { my $self = shift; goto $methods{$self->{primitive}}->{PRIMITIVE}; } |
|
Subroutine
PRIMITIVE: not called CC=1 SCAR=6.9
| |||
| 79 | 6 | ▶ | sub keygen { my $self = shift; goto $methods{$self->{primitive}}->{keygen}; } |
|
Subroutine
keygen: called CC=1 SCAR=0.0
| |||
| 80 | 48 | ▶ | sub shorthash { my $self = shift; goto $methods{$self->{primitive}}->{shorthash}; } |
|
Subroutine
shorthash: called CC=1 SCAR=0.0
| |||
| 81 | |||
| 82 | 1 | 1; | |
| 83 | |||
| 84 | __END__ | ||