1
2<?php
3 //HASH a password with the default algorithm
4 echo password_hash('rasmuslerdorf', PASSWORD_DEFAULT);
5?>
6
7
1function encryptPass($password) {
2 $sSalt = '20adeb83e85f03cfc84d0fb7e5f4d290';
3 $sSalt = substr(hash('sha256', $sSalt, true), 0, 32);
4 $method = 'aes-256-cbc';
5
6 $iv = chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0);
7
8 $encrypted = base64_encode(openssl_encrypt($password, $method, $sSalt, OPENSSL_RAW_DATA, $iv));
9 return $encrypted;
10}
11
12function decryptPass($password) {
13 $sSalt = '20adeb83e85f03cfc84d0fb7e5f4d290';
14 $sSalt = substr(hash('sha256', $sSalt, true), 0, 32);
15 $method = 'aes-256-cbc';
16
17 $iv = chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0);
18
19 $decrypted = openssl_decrypt(base64_decode($password), $method, $sSalt, OPENSSL_RAW_DATA, $iv);
20 return $decrypted;
21}
1function encryptPass($password) {
2 $sSalt = '$2y$10$1qb2f.Xd9CVpaeozsH2CFeaXSTqxXgq/EHvtkNYoH.zyd7gsIEo7q';
3 $sSalt = substr(hash('sha256', $sSalt, true), 0, 32);
4 $method = 'aes-256-cbc';
5
6 $iv = chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0);
7
8 $encrypted = base64_encode(openssl_encrypt($password, $method, $sSalt, OPENSSL_RAW_DATA, $iv));
9 return $encrypted;
10}
11
12function decryptPass($password) {
13 $sSalt = '$2y$10$1qb2f.Xd9CVpaeozsH2CFeaXSTqxXgq/EHvtkNYoH.zyd7gsIEo7q';
14 $sSalt = substr(hash('sha256', $sSalt, true), 0, 32);
15 $method = 'aes-256-cbc';
16
17 $iv = chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0);
18
19 $decrypted = openssl_decrypt(base64_decode($password), $method, $sSalt, OPENSSL_RAW_DATA, $iv);
20 return $decrypted;
21}