John Davidson

php - Laravel encrypter return error with generated key

0 comments
Message:


I tried to encrypt value using Illuminate\Encryption\Encrypter but it returns an error.


Error:


{ "message": "Unsupported cipher or incorrect key length. Supported ciphers are: aes-128-cbc, aes-256-cbc, aes-128-gcm, aes-256-gcm.", "exception": "RuntimeException",....

code:


  $encrypter = new Encrypter("evsLYhBx1UAKKervjVIt1aJK0KLHHIf0vETUeI0HaYc=", config('app.cipher'));
$encryptedValue = $encrypter->encryptString("test value");

My app.cipher


'cipher' => 'AES-256-CBC',

It returns an error that my key is not valid.


I also tried to generate key using this code but it's not working as well.


  $key = base64_encode(
Encrypter::generateKey(config('app.cipher'))
);

I also tried to copy the value of APP_KEY of .env key but not working too.


APP_KEY=base64:evsLYhBx1UAKKervjVIt1aJK0KLHHIf0vETUeI0HaYc=

How to generate a Key to use by lluminate\Encryption\Encrypter ?



My Answer:
message: "The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths."}

Rate this post

4 of 5 based on 8300 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us