+ 2

SHA-512 AES

Help please!! I need to hass a password with SHA-512 AES, how can I do it using php? some example are welcome. Thanks.

14th Jan 2018, 8:00 PM
Sergio Araya Villalobos
Sergio Araya Villalobos - avatar
4 ответов
+ 10
I hope this link can help you somehow: http://php.net/manual/en/function.hash.php Hth, cmiiw
14th Jan 2018, 9:04 PM
Ipang
+ 5
Well done @Sergio, thanks for sharing this : )
19th Jan 2018, 3:47 AM
Ipang
+ 2
I have solve it!: public function cryptMyPass($plaintext){ $password = '#D-$1gnD3skT0p!#'; $method = 'AES-128-CBC'; // Must be exact 32 chars (256 bit) $password = substr(hash('sha512', $password, true), 0, 32); // IV must be exact 16 chars (128 bit) $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); // av3DYGLkwBsErphcyYp+imUW4QKs19hUnFyyYcXwURU= $encrypted = base64_encode(openssl_encrypt($plaintext, $method, $password, OPENSSL_RAW_DATA, $iv)); return $encrypted; }
19th Jan 2018, 2:16 AM
Sergio Araya Villalobos
Sergio Araya Villalobos - avatar
+ 1
If you are using a hash function you ahould take into account that in some algorithms, different inputs may get the same output, in your case, different passwords may get hashed into the same value and be undifferentiable due to the hash function not being reversible
15th Jan 2018, 12:01 PM
spcan
spcan - avatar