mirror of
https://github.com/EnergyMech/energymech.git
synced 2025-12-29 16:14:43 +00:00
sha passwords
This commit is contained in:
45
config/pw.c
45
config/pw.c
@@ -1,27 +1,48 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/*
|
||||
The glibc2 version of this function supports additional encryption algorithms.
|
||||
|
||||
If salt is a character string starting with the characters "$id$" followed by a string terminated by "$":
|
||||
|
||||
$id$salt$encrypted
|
||||
|
||||
then instead of using the DES machine, id identifies the encryption method used and this then determines how the rest of the password string is inter-
|
||||
preted. The following values of id are supported:
|
||||
|
||||
ID | Method
|
||||
---------------------------------------------------------
|
||||
1 | MD5
|
||||
2a | Blowfish (not in mainline glibc; added in some
|
||||
| Linux distributions)
|
||||
5 | SHA-256 (since glibc 2.7)
|
||||
6 | SHA-512 (since glibc 2.7)
|
||||
|
||||
*/
|
||||
|
||||
char * CRYPT_FUNC (const char *, const char *);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char *enc;
|
||||
int md5,des;
|
||||
int md5,sha;
|
||||
|
||||
md5 = sha = 0;
|
||||
|
||||
enc = CRYPT_FUNC ("abc","$6$");
|
||||
if (enc && !strcmp(enc,"$6$$K7EQl9xnonG1x970hnNPqFQKlunsvbFHwzYLnbANzfHjxbphBMjLilW7SKO5EQOidBzcHseqkDOBCSPD8a3CR0"))
|
||||
sha = 1;
|
||||
|
||||
des = md5 = 0;
|
||||
enc = CRYPT_FUNC ("password","$1$XX");
|
||||
if (enc && !strcmp(enc,"$1$XX$HxaXRcnpWZWDaXxMy1Rfn0"))
|
||||
md5 = 1;
|
||||
enc = CRYPT_FUNC ("password","XX");
|
||||
if (enc && !strcmp(enc,"XXq2wKiyI43A2"))
|
||||
des = 1;
|
||||
|
||||
if (md5 && des)
|
||||
write(1,"DESaMD5\n",8);
|
||||
else
|
||||
if (des)
|
||||
write(1,"DES\n",4);
|
||||
else
|
||||
if (sha)
|
||||
write(1,"SHA",3);
|
||||
if (md5)
|
||||
write(1,"MD5\n",4);
|
||||
write(1,"MD5",3);
|
||||
write(1,"\n",1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
1
config/sha1.h
Symbolic link
1
config/sha1.h
Symbolic link
@@ -0,0 +1 @@
|
||||
../src/sha/sha1.h
|
||||
1
config/sha_internal.c
Symbolic link
1
config/sha_internal.c
Symbolic link
@@ -0,0 +1 @@
|
||||
../src/sha/sha1.c
|
||||
Reference in New Issue
Block a user