Войти

Показать полную графическую версию : как сгенерить пароль с помощью crypt ???


Vlad Drakula
06-04-2008, 13:13
как сгенерить пароль с помощью crypt ???

ruslandh
06-04-2008, 14:10
Это функция языка C (может и в perl есть что-то аналогичное) - написать программку.

man p crypt

SYNOPSIS
#include <unistd.h>

char *crypt(const char *key, const char *salt);

DESCRIPTION
The crypt() function is a string encoding function. The algorithm is
implementation-defined.

The key argument points to a string to be encoded. The salt argument is
a string chosen from the set:

a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9 . /

....
The putpwent() function, used in the following example, is not part of
IEEE Std 1003.1-2001

#include <unistd.h>
#include <pwd.h>
#include <string.h>
#include <stdio.h>
...
int valid_change;
int pfd; /* Integer for file descriptor returned by open(). */
FILE *fpfd; /* File pointer for use in putpwent(). */
struct passwd *p;
char user[100];
char oldpasswd[100];
char newpasswd[100];
char savepasswd[100];
...
valid_change = 0;
while ((p = getpwent()) != NULL) {
/* Change entry if found. */
if (strcmp(p->pw_name, user) == 0) {
if (strcmp(p->pw_passwd, crypt(oldpasswd, p->pw_passwd)) == 0) {
strcpy(savepasswd, crypt(newpasswd, user));
p->pw_passwd = savepasswd;
valid_change = 1;
}
else {
fprintf(stderr, "Old password is not valid\n");
}
}
/* Put passwd entry into ptmp. */
putpwent(p, fpfd);
}

Vlad Drakula
07-04-2008, 18:46
но на самом деле можно сделать проще: написать две строчки на PHP

ruslandh
07-04-2008, 22:08
Vlad Drakula, php для меня тёмный лес :)




© OSzone.net 2001-2012