File: MySQL.pm

package info (click to toggle)
libcrypt-mysql-perl 0.04-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 116 kB
  • sloc: perl: 20; makefile: 2
file content (55 lines) | stat: -rw-r--r-- 1,147 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package Crypt::MySQL;

use strict;
use vars qw($VERSION @ISA @EXPORT_OK);
use Digest::SHA qw(sha1 sha1_hex);

BEGIN {
    $VERSION = '0.04';
    if ($] > 5.006) {
        require XSLoader;
        XSLoader::load(__PACKAGE__, $VERSION);
    } else {
        require DynaLoader;
        @ISA = qw(DynaLoader);
        __PACKAGE__->bootstrap;
    }
    require Exporter;
    push @ISA, 'Exporter';
    @EXPORT_OK = qw(password password41);
}

sub password41($) { "*".uc(sha1_hex(sha1($_[0]))); }

1;
__END__

=head1 NAME

Crypt::MySQL - emulate MySQL PASSWORD() function.

=head1 SYNOPSIS

  use Crypt::MySQL qw(password password41);

  my $encrypted = password("foobar"); # for MySQL 3.23, 4.0

  my $encrypted = password41("foobar"); # for MySQL 4.1 or later.

=head1 DESCRIPTION

Crypt::MySQL emulates MySQL PASSWORD() SQL function, without libmysqlclient.
You can compare encrypted passwords, without real MySQL environment.

=head1 AUTHOR

IKEBE Tomohiro E<lt>ikebe@shebang.jpE<gt>

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=head1 SEE ALSO

L<DBD::mysql> L<Digest::SHA>

=cut