Egg::Model::Auth::Crypt::SHA1 - AUTH component to treat code of attestation data with Digest::SHA1.


Egg-Release-Authorize documentation Contained in the Egg-Release-Authorize distribution.

Index


Code Index:

NAME

Top

Egg::Model::Auth::Crypt::SHA1 - AUTH component to treat code of attestation data with Digest::SHA1.

SYNOPSIS

Top

  package MyApp::Model::Auth::MyAuth;
  ..........

  __PACKAGE__->config(
    crypt_sha1_salt => 'abcd1234',
    );

  __PACKAGE__->setup_api( File => qw/ Crypt::SHA1 / );

DESCRIPTION

Top

It is API component to treat the password in the attestation data with Digest::SHA1.

'Crypt::SHA1' is included in the list following API component name specified for 'setup_api' method.

  __PACKAGE__->setup_api( DBI => qw/ Crypt::SHA1 / );

When 'crypt_sha1_salt' of the configuration is set, the character string that connects the content behind former password comes to be used to generate checksum.

METHODS

Top

password_check ([CRYPT_PASSWORD], [INPUT_PAWWORD])

The agreement of CRYPT_PASSWORD and INPUT_PAWWORD is confirmed.

create_password ([PLAIN_PASSWORD])

PLAIN_PASSWORD is encrypted.

valid_crypt ([CRYPT_PASSWORD])

CRYPT_PASSWORD is HEX value of 32 digits or it confirms it.

SEE ALSO

Top

Egg::Release, Egg::Model::Auth, Egg::Model::Auth::Base::API, Digest::SHA1,

AUTHOR

Top

Masatoshi Mizuno <lushe&64;cpan.org>

COPYRIGHT AND LICENSE

Top


Egg-Release-Authorize documentation Contained in the Egg-Release-Authorize distribution.

package Egg::Model::Auth::Crypt::SHA1;
#
# Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
#
# $Id: SHA1.pm 347 2008-06-14 18:57:53Z lushe $
#
use strict;
use warnings;
use Carp qw/ croak /;
use Digest::SHA1 qw/ sha1_hex /;

our $VERSION= '0.01';

sub _setup {
	my($class, $e)= @_;
	$class->config->{crypt_sha1_salt} ||= "";
	$class->next::method($e);
}
sub password_check {
	my $self = shift;
	my $crypt= shift || croak 'I want crypt string.';
	   $crypt=~s{^\s+} []; $crypt=~s{\s+$} [];
	$crypt eq $self->create_password(@_) ? 1: 0;
}
sub create_password {
	my $self    = shift;
	my $password= shift || croak 'I want password.';
	   $password=~s{^\s+} []; $password=~s{\s+$} [];
	sha1_hex($password. $self->config->{crypt_sha1_salt});
}
sub valid_crypt {
	($_[1] and $_[1]=~m{^[a-f0-9]{40}$}) ? 1: 0;
}

1;

__END__