Read mysql manual.
This indeed is a standard crypt function in unix.

Here is the excerpts:

ENCRYPT(str[,salt])

Encrypt str using the Unix crypt() system call. The salt argument should be
a string with two characters. (As of MySQL Version 3.22.16, salt may be
longer than two characters.):

mysql> SELECT ENCRYPT("hello");
        -> 'VxuFAJXVARROc'


If crypt() is not available on your system, ENCRYPT() always returns NULL.
ENCRYPT() ignores all but the first 8 characters of str, at least on some
systems. This will be determined by the behaviour of the underlying crypt()
system call.

To reproduce the encrypted string from the plain one,
take the first two characters from the encrypted string
and use it as the salt.

e.g.,

mysql> select encrypt("test");
+-----------------+
| encrypt("test") |
+-----------------+
| 0cfyC/f6DlrUU   |
+-----------------+
1 row in set (0.01 sec)

mysql> select encrypt("test","0c");
+----------------------+
| encrypt("test","0c") |
+----------------------+
| 0cfyC/f6DlrUU        |
+----------------------+
1 row in set (0.04 sec)

You can do the same thing with perl and other languages as well.

Regards,

Nat Sakimura

----- Original Message -----
From: "Pedro Venda" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 03, 2003 9:15 PM
Subject: Re: [courier-users] mysql auth not working - updated


> i got it.
>
> > I think I have read some where you should use the
> > mysql encrypt("YourPasswordGoesHere") function. That
> > is what I use and seems to work...... It could explain
> > your problem.
>
> indeed.
>
> yet, don't you think that password() would be better?
> encrypt() uses only the first 8 chars of the password to produce the
encrypted
> string.
>
> also i would like to have an explanation on how encrypt works... because
> ... well, because of this:
>
> mysql> select encrypt("test");
> +-----------------+
> | encrypt("test") |
> +-----------------+
> | 0cfyC/f6DlrUU   |
> +-----------------+
> 1 row in set (0.01 sec)
>
> mysql> select encrypt("test");
> +-----------------+
> | encrypt("test") |
> +-----------------+
> | 1cyNvNOLyQaUQ   |
> +-----------------+
> 1 row in set (0.00 sec)
>
> mysql> select encrypt("test");
> +-----------------+
> | encrypt("test") |
> +-----------------+
> | 4cr13ju9KqhO.   |
> +-----------------+
> 1 row in set (0.00 sec)
>
> mysql> select encrypt("test");
> +-----------------+
> | encrypt("test") |
> +-----------------+
> | 6c4zBFeN4TFZA   |
> +-----------------+
> 1 row in set (0.00 sec)
>
> mysql>
>
> how can the program authenticate the user with the encrypt function? is
> encrypt() reversible? if it is not, how can we be sure that the stored
> string is an encrypt("test") [for example] since consecutive encrypts
> return different strings?
>
> thanks for the help.
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
> http://www.vasoftware.com
> _______________________________________________
> courier-users mailing list
> [EMAIL PROTECTED]
> Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users
>



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
courier-users mailing list
[EMAIL PROTECTED]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to