Difference between revisions of "Generating crypt password hash with given salt"

From Notes_Wiki
(Created page with "=Generating crypt password hash with given salt= Below script can be used to generate password hash for chosen algorithm and salt. Here '1' denotes md5 algorithm and abcd wou...")
 
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Generating crypt password hash with given salt=
[[Main Page|Home]] > [[Security tips]] > [[Generating crypt password hash with given salt]]


Below script can be used to generate password hash for chosen algorithm and salt. Here '1' denotes md5 algorithm and abcd would be used salt. The generated crypt output can be used in /etc/shadow (or /etc/passwd) as password hash.
Below script can be used to generate password hash for chosen algorithm and salt. Here '1' denotes md5 algorithm and abcd would be used salt. The generated crypt output can be used in /etc/shadow (or /etc/passwd) as password hash.
Line 12: Line 12:


The crypt function is available for C programs also through unistd.h. When using crypt the programs have to be linked with '<tt>-lcrypt</tt>' To get more information on crypt function use '<tt>man crypt</tt>'and read 'Glibc notes' in 'NOTES' section of man page.
The crypt function is available for C programs also through unistd.h. When using crypt the programs have to be linked with '<tt>-lcrypt</tt>' To get more information on crypt function use '<tt>man crypt</tt>'and read 'Glibc notes' in 'NOTES' section of man page.
[[Main Page|Home]] > [[Security tips]] > [[Generating crypt password hash with given salt]]

Latest revision as of 04:22, 18 April 2022

Home > Security tips > Generating crypt password hash with given salt

Below script can be used to generate password hash for chosen algorithm and salt. Here '1' denotes md5 algorithm and abcd would be used salt. The generated crypt output can be used in /etc/shadow (or /etc/passwd) as password hash.

<?php
if (CRYPT_MD5 == 1) {
    echo 'MD5:          ' . crypt('password', '$1$abcd$') . "\n";
}
?>

The crypt function is available for C programs also through unistd.h. When using crypt the programs have to be linked with '-lcrypt' To get more information on crypt function use 'man crypt'and read 'Glibc notes' in 'NOTES' section of man page.


Home > Security tips > Generating crypt password hash with given salt