Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i use aes-256 encrypt in postgrepsql?

Tags:

sql

postgresql

I tested this script in Postgresql:

select encode(encrypt('123456','F2388451B0954326','aes'),'BASE64');

But, this is AES128 encryption. How can I use aes-256 encryption in PostgreSQL?

like image 664
seven Avatar asked Oct 29 '25 14:10

seven


1 Answers

You can use pgcrypto extension, install it with:

create extension pgcrypto

now, after pgcrypto installed successfully, use pgp_sym_encrypt function

select encode(pgp_sym_encrypt('123456','F2388451B0954326','compress-algo=1, cipher-algo=aes256'),'BASE64');

please note that first parameter '123456' is data, second parameter is password

hope that answer your question

like image 199
Susilo Avatar answered Nov 01 '25 09:11

Susilo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!