package CryptX; use strict; use warnings ; our $VERSION = '0.068'; require XSLoader; XSLoader::load('CryptX', $VERSION); use Carp; my $has_json; BEGIN { if (eval { require Cpanel::JSON::XS }) { Cpanel::JSON::XS->import(qw(encode_json decode_json)); $has_json = 1; } elsif (eval { require JSON::XS }) { JSON::XS->import(qw(encode_json decode_json)); $has_json = 2; } elsif (eval { require JSON::PP }) { JSON::PP->import(qw(encode_json decode_json)); $has_json = 3; } else { $has_json = 0; } } sub _croak { die @_ if ref $_[0] || !$_[-1]; if ($_[-1] =~ /^(.*)( at .+ line .+\n$)/s) { pop @_; push @_, $1; } die Carp::shortmess @_; } sub _decode_json { croak "FATAL: cannot find JSON::PP or JSON::XS or Cpanel::JSON::XS" if !$has_json; decode_json(shift); } sub _encode_json { croak "FATAL: cannot find JSON::PP or JSON::XS or Cpanel::JSON::XS" if !$has_json; my $data = shift; my $rv = encode_json($data); # non-canonical fallback return(eval { Cpanel::JSON::XS->new->canonical->encode($data) } || $rv) if $has_json == 1; return(eval { JSON::XS->new->canonical->encode($data) } || $rv) if $has_json == 2; return(eval { JSON::PP->new->canonical->encode($data) } || $rv) if $has_json == 3; return($rv); } 1; =pod =head1 NAME CryptX - Cryptographic toolkit =head1 DESCRIPTION Perl modules providing a cryptography based on L library. =over =item * Symmetric ciphers - see L and related modules L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L =item * Block cipher modes L, L, L, L, L =item * Stream ciphers L, L, L, L, L, L =item * Authenticated encryption modes L, L, L, L, L =item * Hash Functions - see L and related modules L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L =item * Checksums L, L =item * Message Authentication Codes L, L, L, L, L, L, L, L, L =item * Public key cryptography L, L, L, L, L, L =item * Cryptographically secure random number generators - see L and related modules L, L, L, L, L =item * Key derivation functions - PBKDF1, PBKDF2 and HKDF L =item * Other handy functions related to cryptography L =back =head1 LICENSE This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 COPYRIGHT Copyright (c) 2013-2020 DCIT, a.s. L / Karel Miko =cut