Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- python3 -c "import crypt;print(crypt.crypt(input('clear-text pw: '), crypt.mksalt(crypt.METHOD_SHA512)))"
- python -c 'import crypt; print crypt.crypt("test", "$6$random_salt")'
- python3 -c 'import crypt; print(crypt.crypt("test", crypt.mksalt(crypt.METHOD_SHA512)))'
- mkpasswd -m sha-512
- mkpasswd -m md5
- mkpasswd -m help
- Usage: grub-crypt [OPTION]...
- Encrypt a password.
- -h, --helpPrint this message and exit
- -v, --version Print the version information and exit
- --md5 Use MD5 to encrypt the password
- --sha-256 Use SHA-256 to encrypt the password
- **--sha-512 Use SHA-512 to encrypt the password (default)**
- #define _XOPEN_SOURCE
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- int main(int argc, char *argv[]) {
- if ( argc < 3 || (int) strlen(argv[2]) > 16 ) {
- printf("usage: %s password saltn", argv[0]);
- printf("--salt must not larger than 16 charactersn");
- return;
- }
- char salt[21];
- sprintf(salt, "$6$%s$", argv[2]);
- printf("%sn", crypt((char*) argv[1], (char*) salt));
- return;
- }
- /usr/bin/gcc -lcrypt -o passwd-sha512 passwd-sha512.c
- passwd-sha512 <password> <salt (16 chars max)>
- #Set stronger password hasing
- /usr/sbin/authconfig --test | grep sha512 > /dev/null
- if [ $? -ne 0 ]; then
- echo "Configuring sha512 password hashing"
- sudo /usr/sbin/authconfig --enableshadow --passalgo=sha512 --updateall
- fi
- 'password'.crypt('$6$' + rand(36 ** 8).to_s(36))
- #!/usr/bin/env python
- import getpass
- from passlib.hash import sha512_crypt
- if __name__ == "__main__":
- passwd = getpass.getpass('Password to hash: ')
- hash = sha512_crypt.encrypt(passwd)
- print hash
- import crypt, getpass, pwd, string, sys, random
- randomsalt = ""
- password = getpass.getpass()
- choices = string.ascii_uppercase + string.digits + string.ascii_lowercase
- for _ in range(0,8):
- randomsalt += random.choice(choices)
- print crypt.crypt(password, '$6$%s$' % randomsalt)
- $ htpasswd -c /tmp/my_hash user1
- New password:
- Re-type new password:
- Adding password for user user1
- $ cat /tmp/my_hash
- user1:$apr1$oj1ypcQz$4.6lFVtKz2nr8acsQ8hD30
- #!/bin/bash
- read -p "Enter username: " username
- read -s -p "Enter password: " mypassword
- echo
- echo -n $username:$mypassword | chpasswd -S -c SHA512
- 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 encryp‐
- tion method used and this then determines how the rest of the
- password string is interpreted. 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)
- So $5$salt$encrypted is an SHA-256 encoded password and
- $6$salt$encrypted is an SHA-512 encoded one.
Add Comment
Please, Sign In to add comment