MySql WorkBench AES 256 Decryption

后端 未结 3 995
灰色年华
灰色年华 2021-01-28 22:51

I have table with: 1) Encrypted_ID varchar (256) 2) Initialization Vector(iv)varchar(256).

I would like to decrypt the column value using the key

I am using:

3条回答
  •  被撕碎了的回忆
    2021-01-28 23:14

    MySql Workbench worked for me. In my Case, encrypted value was encoded in base 64. So I had to decode base 64 value and IV Using "From_base64" function.

    SET block_encryption_mode = 'aes-256-cbc';
    set @k = 'Key';
    set @iv = From_base64('InitializationVector');
    set @v = from_base64('EncryptedValue');
    select CAST(AES_DECRYPT(@v, @k, @iv) AS CHAR);
    

    Please make sure the encryption type, base 64 encoding, Hex/Unhex of the values/Iv are correct before you start working on the decryption. Review MYSql functions https://dev.mysql.com/doc/refman/8.0/en/string-functions.html

    Hope this helps for someone.

提交回复
热议问题