Chef-REST-Client
view release on metacpan or search on metacpan
lib/Chef/Encoder.pm view on Meta::CPAN
returns sha1 digest in binary encoded with base64 of the data passed.
=cut
#----------------------------#
# class Chef::Encoder::sha1 #
#----------------------------#
sub sha1 {
my $class = shift;
my $param = {@_};
package Chef::Encoder::sha1;
use parent qw { Chef::Encoder };
my $self = {};
bless $self, qw { Chef::Encoder::sha1 };
return $self;
sub digest {
my $self = shift;
my $param = {@_};
my $data = $param->{'data'};
# return undef unless defined $data;
return $self->execute("echo -n '$data'| openssl dgst -sha1 -binary| openssl enc -base64");
}
}#sha1 package ends
=pod
=head2 base64 ( %params)
loads L<Chef::Encoder::base64> class and returns new object of class L<Chef::Encoder::base64>
it accepts ( 'data' => $data )
if none is provided it will try to use the values initialized from parent class L<Chef::Encoder>
=head3 NAME
Chef::Encoder::base64
=head3 VERSION
1.0
=head3 DESCRIPTION
This class provides base64 encoding and ecoding functionality
=head3 METHODS
=head4 B<encode>
it accepts data as parameter $obj->encode( 'data' => $data )
returns base64 encoded value of data
=head4 B<decode>
it accepts data as parameter $obj->decode( 'data' => $data )
returns base64 decoded value of data
=cut
#-------------------------------#
# class Chef::Encoder::base64 #
#-------------------------------#
sub base64 {
my $class = shift;
my $param ={@_};
package Chef::Encoder::base64;
use parent qw { Chef::Encoder };
my $self = {};
bless $self , qw{ Chef::Encoder::base64 };
return $self;
sub encode {
my $self = shift;
my $param = {@_};
my $data = $param->{'data'};
return undef unless defined $data;
return $self->execute("echo '$data'| openssl enc -base64");
}
sub decode {
my $self = shift;
my $param = {@_};
return undef unless defined $data;
return decode_base64( $param->{'data'} );
}
}# base64 package end
1;
=head1 KNOWN BUGS
=head1 SUPPORT
open a github ticket or email comments to Bhavin Patel <bpatel10@nyit.edu>
=head1 COPYRIGHT AND LICENSE
This Software is free to use , licensed under : The Artisic License 2.0 (GPL Compatible)
=cut
( run in 0.657 second using v1.01-cache-2.11-cpan-8644d7adfcd )