package CGI::Session::ID::crypt_openssl;

use strict;
use warnings;

use Crypt::OpenSSL::Random;
use Digest::MD5;
use CGI::Session::ErrorHandler;

$CGI::Session::ID::crypt_openssl::VERSION = '1.00';
@CGI::Session::ID::crypt_openssl::ISA = qw/CGI::Session::ErrorHandler/;

sub generate_id {
	my $self = shift;
	my $random	= Crypt::OpenSSL::Random::random_bytes(16) || $$. time(). rand(time);
	my $md5 = new Digest::MD5();
	$md5->add( $random );
	return $md5->hexdigest();
}

1;

=pod

=head1 NAME

CGI::Session::ID::crypt_openssl - CGI::Session ID driver for generating IDs based on Crypt::OpenSSL::Random

=head1 SYNOPSIS

    use CGI::Session;
    $session = new CGI::Session('id:crypt_openssl', undef);

=head1 DESCRIPTION

Use this module to generate hexadecimal IDs generated with
L<Crypt::OpenSSL::Random> for L<CGI::Session> objects. This library does not
require any arguments. Use this module to generate security IDs with a high
level of randomnes.

=head1 CREDITS

My Sweetheart Sabrina and my lovely childs Jolina and Marcella

=head1 AUTHOR

Helmut Weber <helmut.weber@bitbetrieb.de>

=head1 COPYRIGHT AND LICENSE

Copyright (c) 2010 bitbetrieb. All rights reserved.

This library is free software. You can modify and distribute it under the same terms as Perl itself.

=head1 LAST CHANGES

$Id: crypt_openssl.pm 57 2010-12-10 17:48:22Z hweber $

=head1 SEE ALSO

L<Digest::MD5>,
L<Crypt::OpenSSL::Random>

=cut
