view release on metacpan or search on metacpan
lib/Crypt/Passphrase/Scrypt.pm view on Meta::CPAN
sub recode_hash {
my ($self, $hash) = @_;
return $hash if $self->{format} eq 'libcrypt';
if (my ($encoded_cost, $encoded_block_size, $encoded_parallel, $salt, $encoded_hash) = $hash =~ $regex7) {
my ($cost, $block_size, $parallel) = map { decode_crypt64_number($_) } $encoded_cost, $encoded_block_size, $encoded_parallel;
my $decoded = decode_crypt64($encoded_hash);
my $recoded_hash = encode_base64($decoded, '');
return sprintf '$scrypt$ln=%d,r=%d,p=%d$%s$%s', $cost, $block_size, $parallel, encode_base64($salt, ''), $recoded_hash;
}
return $hash;
}
view all matches for this distribution
view release on metacpan or search on metacpan
t/Crypt-Perl-RSA-PKCS1_v1_5.t view on Meta::CPAN
$_->[0] =~ tr<.><>d for values %strs;
for my $hash_alg (sort keys %strs) {
my $binary = pack 'H*', $strs{$hash_alg}[0];
my $decoded;
lives_ok(
sub {
$decoded = Crypt::Perl::RSA::PKCS1_v1_5::decode($binary, $hash_alg);
},
"decode() succeeds ($hash_alg)",
);
is(
sprintf('%v.02x', $decoded),
$strs{$hash_alg}[1],
"decoded $hash_alg payload",
);
}
done_testing();
view all matches for this distribution
view release on metacpan or search on metacpan
t/05encoding.t view on Meta::CPAN
my $byte_str = "\xe9";
ok(!utf8::is_utf8($byte_str), 'byte string has no UTF-8 flag');
# Same character but with UTF-8 flag set via Encode::decode
my $utf8_str = Encode::decode('latin-1', "\xe9");
ok(utf8::is_utf8($utf8_str), 'decoded string has UTF-8 flag');
# Both should produce the same hash (SvPVbyte downgrades)
my $ctx1 = Crypt::RIPEMD160->new;
$ctx1->add($byte_str);
my $hex1 = unpack("H*", $ctx1->digest);
t/05encoding.t view on Meta::CPAN
};
subtest 'UTF-8 flagged ASCII string matches byte string' => sub {
my $byte_str = "hello";
my $utf8_str = Encode::decode('UTF-8', "hello");
ok(utf8::is_utf8($utf8_str), 'decoded ASCII has UTF-8 flag');
my $ctx1 = Crypt::RIPEMD160->new;
$ctx1->add($byte_str);
my $hex1 = unpack("H*", $ctx1->digest);
t/05encoding.t view on Meta::CPAN
subtest 'all Latin-1 bytes match with and without UTF-8 flag' => sub {
my $all_bytes = join('', map { chr($_) } 0..255);
my $utf8_str = Encode::decode('latin-1', $all_bytes);
ok(utf8::is_utf8($utf8_str), 'decoded Latin-1 has UTF-8 flag');
my $ctx1 = Crypt::RIPEMD160->new;
$ctx1->add($all_bytes);
my $hex1 = unpack("H*", $ctx1->digest);
view all matches for this distribution
view release on metacpan or search on metacpan
t/90_rncryptor.t view on Meta::CPAN
};
TODO: {
local $TODO = q{
The length of encryption/hmac key have to be 32,
but the length of the data decoded each value of "enc_key_hex"/"hmac_key_hex"
is only 16. Maybe this is mistake of the test vector.
Thus, The following tests are failed because I cannot guess the real value.
};
subtest 'key' => sub {
my $vp = t::assets::VectorParser->load(3, 'key');
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/RSA.pm view on Meta::CPAN
my $key = $params{Key};
return $self->error ($key->errstr, \%params, $key) unless $key->check();
if ($params{Armour} || $params{Armor}) {
my $decoded = $self->{pp}->unarmour ($cyphertext) ||
return $self->error ($self->{pp}->errstr());
$cyphertext = $$decoded{Content}{Cyphertext}
}
my $plaintext;
my $blocksize = blocksize ( $$self{es}->decryptblock (Key => $key),
length($cyphertext)
lib/Crypt/RSA.pm view on Meta::CPAN
sub verify {
my ($self, %params) = @_;
if ($params{Armour} || $params{Armor}) {
my $decoded = $self->{pp}->unarmour ($params{Signature}) ||
return $self->error ($self->{pp}->errstr());
$params{Signature} = $$decoded{Content}{Signature}
}
my $verify = $self->{ss}->verify (%params) ||
return $self->error ($self->{ss}->errstr, $params{Key}, \%params);
view all matches for this distribution
view release on metacpan or search on metacpan
1.14 - 2019-06-14
* Fix UINT32 and UINT8 for musl libc
1.13 - 2015-05-23
* Correctly null-terminate encoded/decoded strings (RT 769/#5)
1.12 - 2014-01-03
* Get rid of MYMETA
1.11 - 2012-07-28
view all matches for this distribution
view release on metacpan or search on metacpan
look for the matching round key from inside the module to do real job.
=head2 Important notes on Encoding
Please, E<lt>DO NOT use encoding 'blah';.E<gt>
I could not figure out how to restore those decoded bytes into an SV variable
in the script where 'use encoding...' inserted.
Do you know ? Let me know, please.
=head2 EXPORT
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/SaltedHash.pm view on Meta::CPAN
Return corresponding Boolean value
Our job is to split the original digest up into 2 distinct byte arrays, one of the left 20 (0 - 20 including the null terminator) bytes and
the other for the rest of the data. The left 0 � 20 bytes will represent the salted binary value we will use for a byte-by-byte data
match against the new clear text presented for verification. The string presented for verification will have to be salted as well. The rest
of the bytes (21 � 32) represent the random salt which when decoded will show the exact hex characters that make up the once randomly
generated seed.
We are now ready to verify some data. Let's start with the 4 hashes presented earlier. We will run them through our code to extract the
random salt and then using that verify the clear text string hashed by slappasswd. First, let's do a verification test with an erroneous
password; this should fail the matching test:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/SecretBuffer/PEM.pm view on Meta::CPAN
=head2 content
A L<Span|Crypt::SecretBuffer::Span> or SecretBuffer that contains the bytes of the PEM payload.
This span created by L</parse> has C<< encoding => BASE64 >> set, which affects the
character-based methods like C<parse>, but has not actually been Base64-decoded, which matters
for methods like C<length> or C<memcmp>.
=head1 METHODS
=head2 serialize
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/Sodium/XS/Base64.pm view on Meta::CPAN
Identical to L<MIME::Base64/decode_base64url>. Stops parsing at any invalid
base64 bytes. C<$bytes> will be empty if C<$string> could not be validly
interpreted as base64 (i.e., if the output would not be a multiple of 8 bits).
Returns the base64 decoded bytes.
=head2 sodium_bin2base64
my $string = sodium_bin2base64($bytes);
my $string = sodium_bin2base64($bytes, $variant);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/TimestampedData.pm view on Meta::CPAN
Creates a new Crypt::TimestampedData object with the provided arguments.
=head2 read_file($filepath)
Reads and decodes a .TSD file from the specified path. Returns a hash reference
containing the decoded TimeStampedData structure.
=head2 write_file($filepath, $tsd_hashref)
Encodes and writes a TimeStampedData structure to the specified file path.
lib/Crypt/TimestampedData.pm view on Meta::CPAN
sub decode_der {
my ($class, $der) = @_;
# Try direct TimeStampedData first
my $decoded = $TSD_CODEC->decode($der);
return $decoded if defined $decoded;
# If that fails, try unwrapping CMS ContentInfo (common packaging for TSD)
my $ci = $CONTENTINFO_CODEC->decode($der);
die 'ASN.1 decode failed: ' . $TSD_CODEC->error unless defined $ci;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/Trifid.pm view on Meta::CPAN
use Crypt::Trifid;
my $crypt = Crypt::Trifid->new;
my $message = 'TRIFID';
my $encoded = $crypt->encode($message);
my $decoded = $crypt->decode($encoded);
print "Encoded message: [$encoded]\n";
print "Decoded message: [$decoded]\n";
=head1 METHODS
=head2 encode($message)
lib/Crypt/Trifid.pm view on Meta::CPAN
return $encoded;
}
=head2 decode($encoded_message)
It takes an encoded message as scalar string and returns the decoded message.
use strict; use warnings;
use Crypt::Trifid;
my $crypt = Crypt::Trifid->new;
my $message = 'TRIFID';
my $encoded = $crypt->encode($message);
my $decoded = $crypt->decode($encoded);
print "Encoded message: [$encoded]\n";
print "Decoded message: [$decoded]\n";
=cut
sub decode {
my ($self, $message) = @_;
lib/Crypt/Trifid.pm view on Meta::CPAN
push @{$_chars->[$i]}, @nodes[$index..($index+$j-1)];
$index += $j;
$i++;
}
my $decoded = '';
foreach (1..$j) {
my $x = $_chars->[0]->[$_-1];
my $y = $_chars->[1]->[$_-1];
my $z = $_chars->[2]->[$_-1];
$decoded .= $_chart->{sprintf("%d%d%d", $x, $y, $z)};
}
return $decoded;
}
#
#
# PRIVATE METHODS
view all matches for this distribution
view release on metacpan or search on metacpan
cmp_ok( $binary, "ne", $encoded, "encoded != binary" );
cmp_ok( length($binary), "<", length($encoded), "encoded is longer" );
is( $c->decrypt_string( string => $encoded, decode => 1 ), $c->decrypt_string( string => $binary ), "decoded == binary" );
}
ok( !$c->has_default_digest, "no default digest" );
my $fallback_digest = eval { $c->fallback_digest };
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/X509/CRL.pm view on Meta::CPAN
=head1 SYNOPSIS
use Crypt::X509::CRL;
$decoded = Crypt::X509::CRL->new( crl => $crl );
$subject_email = $decoded->subject_email;
print "do not use after: ".gmtime($decoded->not_after)." GMT\n";
=head1 REQUIRES
Convert::ASN1
lib/Crypt/X509/CRL.pm view on Meta::CPAN
=head2 new ( OPTIONS )
Creates and returns a parsed X.509 CRL hash, containing the parsed
contents. The data is organised as specified in RFC 2459.
By default only the first ASN.1 Layer is decoded. Nested decoding
is done automagically through the data access methods.
=over 4
=item crl =E<gt> $crl
lib/Crypt/X509/CRL.pm view on Meta::CPAN
=head3 Example:
use Crypt::X509::CRL;
use Data::Dumper;
$decoded = Crypt::X509::CRL->new( crl => $crl );
print Dumper $decoded;
=cut back
=head1 METHODS
lib/Crypt/X509/CRL.pm view on Meta::CPAN
Returns the last error from parsing, C<undef> when no error occured.
This error is updated on deeper parsing with the data access methods.
=head3 Example:
$decoded= Crypt::X509::CRL->new(crl => $crl);
if ( $decoded->error ) {
warn "Error on parsing Certificate Revocation List: ", $decoded->error;
}
=cut back
=head1 DATA ACCESS METHODS
lib/Crypt/X509/CRL.pm view on Meta::CPAN
Returns either the utcTime or generalTime of the certificate revocation list's date
of publication. Returns undef if not defined.
=head3 Example:
$decoded = Crypt::X509::CRL->new(crl => $crl);
print "CRL was published at ", gmtime( $decoded->this_update ), " GMT\n";
=cut back
=head2 next_update
Returns either the utcTime or generalTime of the certificate revocation list's
date of expiration. Returns undef if not defined.
=head3 Example:
$decoded = Crypt::X509::CRL->new(crl => $crl);
if ( $decoded->next_update < time() ) {
warn "CRL has expired!";
}
=cut back
lib/Crypt/X509/CRL.pm view on Meta::CPAN
Returns the certificate's signature algorithm as an OID string.
=head3 Example:
$decoded = Crypt::X509::CRL->new(crl => $crl);
print "CRL signature is encrypted with:", $decoded->signature_algorithm, "\n";
Example Output: CRL signature is encrypted with: 1.2.840.113549.1.1.5
=cut back
lib/Crypt/X509/CRL.pm view on Meta::CPAN
Returns the signature encryption algorithm (e.g. 'RSA') as a string.
=head3 Example:
$decoded = Crypt::X509::CRL->new(crl => $crl);
print "CRL signature is encrypted with:", $decoded->SigEncAlg, "\n";
Example Output: CRL signature is encrypted with: RSA
=cut back
lib/Crypt/X509/CRL.pm view on Meta::CPAN
Returns the signature hashing algorithm (e.g. 'SHA1') as a string.
=head3 Example:
$decoded = Crypt::X509::CRL->new(crl => $crl);
print "CRL signature is hashed with:", $decoded->SigHashAlg, "\n";
Example Output: CRL signature is encrypted with: SHA1
=cut back
lib/Crypt/X509/CRL.pm view on Meta::CPAN
issuer (= the DN of the CA). Attribute names for the most common Attributes
are translated from the OID-Numbers, unknown numbers are output verbatim.
=head3 Example:
$decoded = Crypt::X509::CRL->new( $crl );
print "CRL was issued by: ", join( ', ' , @{ $decoded->Issuer } ), "\n";
=cut back
=head2 issuer_cn
lib/Crypt/X509/CRL.pm view on Meta::CPAN
Returns the authority key identifier as a bit string.
=head3 Example:
$decoded = Crypt::X509::CRL->new( $crl );
my $s = unpack("H*" , $decoded->key_identifier);
print "The Authority Key Identifier in HEX is: $s\n";
Example output:
The Authority Key Identifier in HEX is: 86595f93caf32da620a4f9595a4a935370e792c9
lib/Crypt/X509/CRL.pm view on Meta::CPAN
OID-Numbers, unknown numbers are output verbatim. Returns undef if the
extension is not set in the certificate.
=head3 Example:
$decoded = Crypt::X509::CRL->new($cert);
print "Certificate was authorised by:", join( ', ', @{ $decoded->authorityCertIssuer } ), "\n";
=cut back
=head2 authority_serial
lib/Crypt/X509/CRL.pm view on Meta::CPAN
Returns the Issuing Distribution Points as a hash providing for the default values.
=head3 Example:
print "Issuing Distribution Points:\n";
my $IDPs = $decoded->IDPs;
for my $key ( sort keys %{ $IDPs } ) {
print "$key = ";
if ( defined $IDPs->{ $key } ) {
print $IDPs->{ $key }, "\n";
} else {
lib/Crypt/X509/CRL.pm view on Meta::CPAN
keys to the hash are the certificate serial numbers in decimal format.
=head3 Example:
print "Revocation List:\n";
my $rls = $decoded->revocation_list;
my $count_of_rls = keys %{ $rls };
print "Found $count_of_rls revoked certificate(s) on this CRL.\n";
for my $key ( sort keys %{ $rls } ) {
print "Certificate: ", DecimalToHex( $key ), "\n";
for my $extn ( sort keys %{ $rls->{ $key } } ) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/X509.pm view on Meta::CPAN
=head1 SYNOPSIS
use Crypt::X509;
$decoded = Crypt::X509->new( cert => $cert );
$subject_email = $decoded->subject_email;
print "do not use after: ".gmtime($decoded->not_after)." GMT\n";
=head1 REQUIRES
Convert::ASN1
lib/Crypt/X509.pm view on Meta::CPAN
=head2 new ( OPTIONS )
Creates and returns a parsed X.509 certificate hash, containing the parsed
contents. The data is organised as specified in RFC 2459.
By default only the first ASN.1 Layer is decoded. Nested decoding
is done automagically through the data access methods.
=over 4
=item cert =E<gt> $certificate
lib/Crypt/X509.pm view on Meta::CPAN
=back
use Crypt::X509;
use Data::Dumper;
$decoded= Crypt::X509->new(cert => $cert);
print Dumper($decoded);
=cut back
sub new {
my ( $class, %args ) = @_;
lib/Crypt/X509.pm view on Meta::CPAN
Returns the last error from parsing, C<undef> when no error occured.
This error is updated on deeper parsing with the data access methods.
$decoded= Crypt::X509->new(cert => $cert);
if ($decoded->error) {
warn "Error on parsing Certificate:".$decoded->error;
}
=cut back
sub error {
lib/Crypt/X509.pm view on Meta::CPAN
returns the serial number (integer or Math::BigInt Object, that gets automagic
evaluated in scalar context) from the certificate
$decoded= Crypt::X509->new(cert => $cert);
print "Certificate has serial number:".$decoded->serial."\n";
=cut back
sub serial {
my $self = shift;
lib/Crypt/X509.pm view on Meta::CPAN
hold the timesamps as "generalTime"-entries. B<The contents of "generalTime"-entries
are not well defined in the RFC and
are returned by this module unmodified>, if no utcTime-entry is found.
$decoded= Crypt::X509->new(cert => $cert);
if ($decoded->notBefore < time()) {
warn "Certificate: not yet valid!";
}
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
hold the timesamps as "generalTime"-entries. B<The contents of "generalTime"-entries
are not well defined in the RFC and
are returned by this module unmodified>, if no utcTime-entry is found.
$decoded= Crypt::X509->new(cert => $cert);
print "Certificate expires on ".gmtime($decoded->not_after)." GMT\n";
=cut back
sub not_after {
my $self = shift;
lib/Crypt/X509.pm view on Meta::CPAN
=head2 PubKeyAlg
returns the subject public key encryption algorithm (e.g. 'RSA') as string.
$decoded= Crypt::X509->new(cert => $cert);
print "Certificate public key is encrypted with:".$decoded->PubKeyAlg."\n";
Example Output: Certificate public key is encrypted with: RSA
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
=head2 sig_algorithm
Returns the certificate's signature algorithm as OID string
$decoded= Crypt::X509->new(cert => $cert);
print "Certificate signature is encrypted with:".$decoded->sig_algorithm."\n";>
Example Output: Certificate signature is encrypted with: 1.2.840.113549.1.1.5
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
=head2 SigEncAlg
returns the signature encryption algorithm (e.g. 'RSA') as string.
$decoded= Crypt::X509->new(cert => $cert);
print "Certificate signature is encrypted with:".$decoded->SigEncAlg."\n";
Example Output: Certificate signature is encrypted with: RSA
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
=head2 SigHashAlg
returns the signature hashing algorithm (e.g. 'SHA1') as string.
$decoded= Crypt::X509->new(cert => $cert);
print "Certificate signature is hashed with:".$decoded->SigHashAlg."\n";
Example Output: Certificate signature is encrypted with: SHA1
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
returns a pointer to an array of strings containing subject nameparts of the
certificate. Attributenames for the most common Attributes are translated
from the OID-Numbers, unknown numbers are output verbatim.
$decoded= Convert::ASN1::X509->new($cert);
print "DN for this Certificate is:".join(',',@{$decoded->Subject})."\n";
=cut back
sub Subject {
my $self = shift;
lib/Crypt/X509.pm view on Meta::CPAN
returns a pointer to an array of strings building the DN of the certificate
issuer (= the DN of the CA). Attributenames for the most common Attributes
are translated from the OID-Numbers, unknown numbers are output verbatim.
$decoded= Crypt::X509->new($cert);
print "Certificate was issued by:".join(',',@{$decoded->Issuer})."\n";
=cut back
sub Issuer {
my $self = shift;
my ( $i, $type );
lib/Crypt/X509.pm view on Meta::CPAN
for this certificate. C<undef> is returned, when the extension is not set in the
certificate.
If the extension is marked critical, this is also reported.
$decoded= Crypt::X509->new(cert => $cert);
print "Allowed usages for this Certificate are:\n".join("\n",@{$decoded->KeyUsage})."\n";
Example Output:
Allowed usages for this Certificate are:
critical
digitalSignature
lib/Crypt/X509.pm view on Meta::CPAN
C<undef> if the extension is not filled. OIDs of the following ExtKeyUsages are known:
serverAuth, clientAuth, codeSigning, emailProtection, timeStamping, OCSPSigning
If the extension is marked critical, this is also reported.
$decoded= Crypt::X509->new($cert);
print "ExtKeyUsage extension of this Certificates is: ", join(", ", @{$decoded->ExtKeyUsage}), "\n";
Example Output: ExtKeyUsage extension of this Certificates is: critical, serverAuth
=cut back
our %oid2extkeyusage = (
lib/Crypt/X509.pm view on Meta::CPAN
C<undef> if the extension is not filled. Usually this Extension holds the e-Mail
address for person-certificates or DNS-Names for server certificates.
It also pre-pends the field type (ie rfc822Name) to the returned value.
$decoded= Crypt::X509->new($cert);
print "E-Mail or Hostnames in this Certificates is/are:", join(", ", @{$decoded->SubjectAltName}), "\n";
Example Output: E-Mail or Hostnames in this Certificates is/are: rfc822Name=user@server.com
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
=head2 DecodedSubjectAltNames
Returns a pointer to an array of strings containing all the alternative subject name
extensions.
Each such extension is represented as a decoded ASN.1 value, i.e. a pointer to a list
of pointers to objects, each object having a single key with the type of the alternative
name and a value specific to that type.
Example return value:
lib/Crypt/X509.pm view on Meta::CPAN
returns a pointer to an array of strings building the DN of the Authority Cert
Issuer. Attributenames for the most common Attributes
are translated from the OID-Numbers, unknown numbers are output verbatim.
undef if the extension is not set in the certificate.
$decoded= Crypt::X509->new($cert);
print "Certificate was authorised by:".join(',',@{$decoded->authorityCertIssuer})."\n";
=cut back
sub authorityCertIssuer {
my $self = shift;
lib/Crypt/X509.pm view on Meta::CPAN
=head2 EntrustVersionInfo
Returns the EntrustVersion as a string
print "Entrust Version: ", $decoded->EntrustVersion, "\n";
Example Output: Entrust Version: V7.0
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
=head2 SubjectDirectoryAttributes
Returns the SubjectDirectoryAttributes as an array of key = value pairs, to include a data type
print "Subject Directory Attributes: ", join( ', ' , @{ $decoded->SubjectDirectoryAttributes } ), "\n";
Example Output: Subject Directory Attributes: 1.2.840.113533.7.68.29 = 7 (integer)
=cut back
lib/Crypt/X509.pm view on Meta::CPAN
=head2 SubjectInfoAccess
Returns the SubjectInfoAccess as an array of hashes with key=value pairs.
print "Subject Info Access: ";
if ( defined $decoded->SubjectInfoAccess ) {
my %SIA = $decoded->SubjectInfoAccess;
for my $key ( keys %SIA ) {
print "\n\t$key: \n\t";
print join( "\n\t" , @{ $SIA{$key} } ), "\n";
}
} else { print "\n" }
lib/Crypt/X509.pm view on Meta::CPAN
Returns the creation timestamp of the corresponding OpenPGP key.
(see http://www.imc.org/ietf-openpgp/mail-archive/msg05320.html)
print "PGPExtension: ";
if ( defined $decoded->PGPExtension ) {
my $creationtime = $decoded->PGPExtension;
printf "\n\tcorresponding OpenPGP Creation Time: ", $creationtime, "\n";
}
Example Output:
PGPExtension:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/ASN1.pm view on Meta::CPAN
my $tree = asn1_decode_der($der_bytes, { int => 'hex', bin => 'hex' });
# --- inspect ---
print asn1_to_string($tree);
# --- encode a decoded tree ---
my $der2 = asn1_encode_der($tree);
# --- build from scratch ---
my $der = asn1_encode_der([{
type => 'SEQUENCE',
lib/Crypt/ASN1.pm view on Meta::CPAN
OCTET_STRING BIT_STRING UTF8_STRING
PRINTABLE_STRING IA5_STRING TELETEX_STRING
UTCTIME GENERALIZEDTIME
SEQUENCE SET CUSTOM
The list above is not exhaustive for decoded input. If the decoder encounters
an ASN.1 tag that does not map to one of the built-in type names above, it is
returned as C<CUSTOM> with the appropriate C<class>, C<constructed>, and
C<tag> fields. This includes unsupported universal tags such as
C<ENUMERATED>, which decode as C<CUSTOM> with C<< class => "UNIVERSAL" >>.
=item C<value> (varies, required for most types)
The decoded value. Its Perl type depends on C<type> and sometimes on the
C<format> key -- see L</Per-type details> below.
=item C<format> (string, decoder sets it, encoder reads it)
Tells the encoder how the C<value> is represented so it can convert it back
lib/Crypt/ASN1.pm view on Meta::CPAN
This works reliably only on Perls with 64-bit integers; on 32-bit integer
Perls, large timestamps may overflow or lose precision.
=item C<oidmap =E<gt> \%map>
A hashref mapping dotted OID strings to friendly names. When a decoded
C<OID> node's value exists as a key in C<%map>, the node gets an additional
C<name> key with the mapped value. Does not affect encoding.
=back
lib/Crypt/ASN1.pm view on Meta::CPAN
shown as lowercase hex, truncated to 64 characters with C<...> for longer
values. C<BIT_STRING> additionally shows the bit count in parentheses.
C<OID> nodes that have a C<name> key (via C<oidmap>) show the name in
parentheses after the dotted value.
The function handles trees decoded with any combination of decode options
(C<int>, C<bin>, C<dt>).
=head1 SEE ALSO
L<CryptX>, L<Crypt::Misc>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypto/NanoRPC.pm view on Meta::CPAN
sub __do_rpc {
my ($self,$json) = @_;
$self->{request}->content($json);
my $response = $self->{ua}->request($self->{request});
if ($response->is_success) {
return decode_json($response->decoded_content);
}
return { error => "RPC call failed" };
}
1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CryptoTron/BroadcastTransaction.pm view on Meta::CPAN
sub encode {
# Assign the argument to the local variable.
my $content = $_[0];
# Decode the content from the response.
my $json_decode = $JSON->decode($content);
# Encode the decoded content from the response.
my $json_encode = $JSON->encode($json_decode);
# Return the encoded content.
return $json_encode;
};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CryptoTron/ClaimReward.pm view on Meta::CPAN
my $content = $_[0];
# Set up the options for the Perl module JSON::PP.
my $json = 'JSON::PP'->new->pretty;
# Decode the content from the response.
my $json_decode = $json->decode($content);
# Encode the decoded content from the response.
my $json_encode = $json->encode($json_decode);
# Return the encoded content.
return $json_encode;
};
lib/CryptoTron/ClaimReward.pm view on Meta::CPAN
# Assign the subroutine argument to the local variable.
my $json_data = $_[0];
# Set up the options for the Perl module JSON::PP.
my $json = 'JSON::PP'->new->pretty;
# Decode the JSON data.
my $decoded = $json->decode($json_data);
# Extract the txID from the JSON data.
my $txID = $decoded->{'txID'};
# Return the extracted txID.
return $txID;
};
# ---------------------------------------------------------------------------- #
lib/CryptoTron/ClaimReward.pm view on Meta::CPAN
# Assign the subroutine argument to the local variable.
my $json_data = $_[0];
# Set up the options for the Perl module JSON::PP.
my $json = 'JSON::PP'->new->pretty;
# Decode the JSON data.
my $decoded = $json->decode($json_data);
# Extract the raw_data from the JSON data.
my $raw_data_hex = $decoded->{'raw_data_hex'};
# Return the extracted raw data.
return $raw_data_hex;
};
# ---------------------------------------------------------------------------- #
lib/CryptoTron/ClaimReward.pm view on Meta::CPAN
# Assign the subroutine argument to the local variable.
my $json_data = $_[0];
# Set up the options for the Perl module JSON::PP.
my $json = 'JSON::PP'->new->pretty;
# Decode the JSON data.
my $decoded = $json->decode($json_data);
# Extract the raw_data from the JSON data.
my $raw_data = $decoded->{'raw_data'};
#$raw_data = to_json($raw_data);
$raw_data = encode_json($raw_data);
# Return the extracted raw data.
return $raw_data;
};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Cucumber/Messages.pm view on Meta::CPAN
=head4 body
The body of the attachment. If `contentEncoding` is `IDENTITY`, the attachment
is simply the string. If it's `BASE64`, the string should be Base64 decoded to
obtain the attachment.
=cut
has body =>
(is => 'ro',
lib/Cucumber/Messages.pm view on Meta::CPAN
);
=head4 content_encoding
Whether to interpret `body` "as-is" (IDENTITY) or if it needs to be Base64-decoded (BASE64).
Content encoding is *not* determined by the media type, but rather by the type
of the object being attached:
- string: IDENTITY
view all matches for this distribution
view release on metacpan or search on metacpan
# Check utf8 and non-utf8 results
sub check_dirs {
my ($test, $utf8, $non_utf8) = @_;
my $utf8_encoded = encode_utf8($utf8);
my $non_utf8_decoded = decode_utf8($non_utf8, FB_CROAK | LEAVE_SRC);
plan tests => 3;
like $utf8 => qr/\/$unicode_dir$/, "$test found correct dir";
is $utf8_encoded => $non_utf8, "$test encoded utf8 dir matches non-utf8";
is $utf8 => $non_utf8_decoded, "$test utf8 dir matches decoded non-utf8";
}
plan tests => 9;
use Cwd;
view all matches for this distribution
view release on metacpan or search on metacpan
use utf8;
# Export du, dw, de, dn, dustr, dwstr, destr, dnstr functions
use D;
# Reference data that contains decoded strings
my $data = [{name => 'ã'}, {name => 'ã'}];
# Encode all strings in reference data to UTF-8 and dump the reference data to STDERR.
du $data;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DAPNET/API.pm view on Meta::CPAN
my($res) = $ua->request($req);
print('Request status line: '.$res->status_line."\n") if($self->{DEBUG}) ;
if (!$res->is_success) {
return($res->status_line);
};
print('JSON Response: '.$res->decoded_content."\n") if($self->{DEBUG});
$self->{_JSONRESPONSEREF} = $jsonresobj->decode($res->decoded_content);
} else {
while (my $substr = substr($text,0,(76 - $self->{_CALL_LEN}),'')) {
if ($i == 1) {
print("substr begining: $substr \n") if($self->{DEBUG});
$json = $self->_json_individual_call($self->{CALLSIGN}.':'.$substr.'...',$to,$txgroup,$emergency);
lib/DAPNET/API.pm view on Meta::CPAN
my($res) = $ua->request($req);
print('Request status line: '.$res->status_line."\n") if($self->{DEBUG});
if (!$res->is_success) {
return($res->status_line);
};
print('JSON Response: '.$res->decoded_content."\n") if($self->{DEBUG});
$self->{_JSONRESPONSEREF} = $jsonresobj->decode($res->decoded_content);
$i++;
};
};
lib/DAPNET/API.pm view on Meta::CPAN
my($res) = $ua->request($req);
print('Request status line: '.$res->status_line."\n") if($self->{DEBUG});
if (!$res->is_success) {
return($res->status_line);
};
print('JSON Response: '.$res->decoded_content."\n") if($self->{DEBUG});
$self->{_JSONRESPONSEREF} = $jsonresobj->decode($res->decoded_content);
} else {
while (my $substr = substr($text,0,(76 - $self->{_CALL_LEN}),'')) {
if ($i == 1) {
print("substr begining: $substr \n") if($self->{DEBUG});
lib/DAPNET/API.pm view on Meta::CPAN
my($res) = $ua->request($req);
print('Request status line: '.$res->status_line."\n") if($self->{DEBUG});
if (!$res->is_success) {
return($res->status_line);
};
print('JSON Response: '.$res->decoded_content."\n") if($self->{DEBUG});
$self->{_JSONRESPONSEREF} = $jsonresobj->decode($res->decoded_content);
$i++;
};
};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DB/CouchDB.pm view on Meta::CPAN
my $req = HTTP::Request->new($method, $uri);
$req->content(Encode::encode('utf8', $content));
my $ua = LWP::UserAgent->new();
my $return = $ua->request($req);
my $response = $return->decoded_content({
default_charset => 'utf8'
});
my $decoded;
eval {
$decoded = $self->json()->decode($response);
};
if ($@) {
return {error => $return->code, reason => $response};
}
return $decoded;
}
package DB::CouchDB::Iter;
sub new {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DB/Object.pm view on Meta::CPAN
If the parameter property I<uri> was provided of if the environment variable C<DB_CON_URI> is set, it will use this connection uri to get the necessary connection parameters values.
An L<URI> could be C<http://localhost:5432?database=somedb> or C<file:/foo/bar?opt={"RaiseError":true}>
Alternatively, if the connection parameter I<conf_file> is provided then its json content will be read and decoded into an hash reference.
The following keys can be used in the json data in the I<conf_file>: C<database>, C<login>, C<passwd>, C<host>, C<port>, C<driver>, C<schema>, C<opt>
The port can be specified in the I<host> parameter by separating it with a semicolon such as C<localhost:5432>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DB2/Admin.pm view on Meta::CPAN
=head2 GetSnapshot
This method performs a database snapshot and returns the collected
snapshot data. It can collect data in one or more monitoring areas,
then returns a hash reference with decoded snapshot results.
This method takes the following named parameters, of which only
C<Subject> is required:
=over 4
view all matches for this distribution
view release on metacpan or search on metacpan
lib/SQL/Amazon/Request/Request.pm view on Meta::CPAN
my $resp = $obj->{_lwp}->post($url_roots{$obj->{_locale}}, $url_params);
if ($dbgname && (! -e $dbgname)) {
open(XMLF, ">$dbgname") || die $!;
print XMLF $resp->decoded_content;
close XMLF;
}
$obj->{_errstr} = 'Amazon ECS request failed: Unknown reason.',
return undef
unless $resp;
$obj->{_errstr} = 'Amazon ECS request failed: ' . $resp->status_line,
return undef
unless $resp->is_success;
$xml = XMLin($resp->decoded_content);
}
$obj->{_errstr} = 'Unable to parse Amazon ECS response.',
return undef
unless $xml;
view all matches for this distribution
view release on metacpan or search on metacpan
* fix compiler warnings:
+ use printf formats matching the arguments
+ use 0 instead of NULL where an integer is expected
+ allocate XSQLDA as char array
+ fix conversion of decimal(x,y) to string
* use the decoded milliseconds when formatting times (also fixes a warning)
* do not link with libdl.so on linux
* fix joined lines in reserved words list
* add new keywords for Firebird 2.5 (part of #12)
* Removed restrictions on distribution
* Readme cleanup
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBD/JDBC.pm view on Meta::CPAN
my ($self, $ber, $arg) = @_;
my ($ber2, $tag, $i, $field);
$self->unpack($ber, \$ber2);
# This value indicates whether or not there's a row to be decoded.
$ber2->decode(INTEGER => \$i);
push @$arg, $i;
if ($i) {
# tag() will return undef when the end of the buffer is reached
view all matches for this distribution
view release on metacpan or search on metacpan
Changes.historic view on Meta::CPAN
(https://github.com/perl5-dbi/DBD-mysql/pull/76)
2016-12-12 Patrick Galbraith, Michiel Beijen, DBI/DBD community (4.041_1)
* Unicode fixes: when using mysql_enable_utf8 or mysql_enable_utf8mb4,
previous versions of DBD::mysql did not properly encode input statements
to UTF-8 and retrieved columns were always UTF-8 decoded regardless of the
column charset.
Fix by Pali Rohár.
Reported and feedback on fix by Marc Lehmann
(https://rt.cpan.org/Public/Bug/Display.html?id=87428)
Also, the UTF-8 flag was not set for decoded data:
(https://rt.cpan.org/Public/Bug/Display.html?id=53130)
* Return INTs with ZEROFILL as strings. Reported by Knarf, fix by Pali Rohár.
(https://rt.cpan.org/Public/Bug/Display.html?id=118977)
2016-11-28 Patrick Galbraith, Michiel Beijen, DBI/DBD community (4.041)
view all matches for this distribution