AES 썸네일형 리스트형 MariaDB AES Encrypt, Decrypt 1. AES로 암호화할 컬럼은 BLOB으로 생성 create table encrypt_test_table ( encrypt_test_id bigint(20) not null auto_increment, encrypted blob not null, primary key (encrypt_test_id) ); 2. AES_ENCRYPT insert into encrypt_test_table (encrypted) values (AES_ENCRYPT('message', SHA2('secret_key', 256))); 3. AES_DECRYPT select AES_DECRYPT(encrypted, SHA2('secret_key', 256)) as decrypted from encrypt_test_table; Node.js AES Encryption, Decryption const crypto = require('crypto'); const algorithm = 'aes-128-cbc'; const secretKey = 'abcdefghijklmnop'; const iv = '00000000000000000000000000000000'; const encrypt = (message) => { const cipher = crypto.createCipheriv(algorithm, Buffer.from(secretKey), Buffer.from(iv, 'hex')); const encrypted = cipher.update(message); return Buffer.concat([encrypted, cipher.final()]).toString('hex'); }; const .. 이전 1 다음