반응형
# testDB생성
mysql> create database test;
Query OK, 1 row affected (0.01 sec)
mysql>
mysql> use test;
Database changed
# test table생성
mysql> create table test
-> (
-> user varchar(100),
-> password varchar(100));
Query OK, 0 rows affected (0.03 sec)
# test table 컬럼 확인
mysql> desc test;
+----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| user | varchar(100) | YES | | NULL | |
| password | varchar(100) | YES | | NULL | |
+----------+--------------+------+-----+---------+-------+
-암호화-
mysql> insert into test values ('my_account', hex(aes_encrypt('123','a')));
Query OK, 1 row affected (0.01 sec)
mysql> select * from test;
+------------+----------------------------------+
| user | password |
+------------+----------------------------------+
| my_account | 22CCF71539A4E25415E1A9B9E31BB6BA |
+------------+----------------------------------+
1 row in set (0.00 sec)
-복호화-
mysql> select user, AES_DECRYPT(unhex(password), 'a') from test;
+------------+-----------------------------------+
| user | AES_DECRYPT(unhex(password), 'a') |
+------------+-----------------------------------+
| my_account | 123 |
+------------+-----------------------------------+
1 row in set (0.00 sec)
반응형
'💾Data > 🧩Database' 카테고리의 다른 글
[MySQL] show_compatibility_56 발생 이유와 해결 방법 (0) | 2022.08.13 |
---|---|
PostgreSQL 외부접속 설정 (0) | 2021.01.27 |
PostgreSQL9.x Install (0) | 2021.01.27 |
MariaDB 10.5 설치 (0) | 2020.09.23 |
MySQL socket Error (0) | 2020.09.16 |