dimanche 7 août 2022

Laravel Generate key for decrypt password

I am working on a code

if (!function_exists('decrypt_password')) {
    function decrypt_password( $iv, $value)
    {
        $key = config('services.decrypt.key');

        $string_iv =hex_to_string($iv);
        $encrypter = new Encrypter($key, 'AES-256-CBC');

        $dec['iv'] = base64_encode($string_iv);
        $dec['value'] = $value;
        $dec['mac'] = hash_hmac('sha256',  $dec['iv'] . $dec['value'], $key);
       
        return ($encrypter->decrypt(base64_encode(json_encode($dec)),false));
    }
}

this piece of code should make a layer of decrypting the password, and key is missing in config and I can't get one or generate a new one. any help!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire