* AES_ENCRYPT 암호화
INSERT INTO 테이블명 VALUES (HEX(AES_ENCRYPT('문자열', '암호화 키')));
* AES_DECRYPT 복호화
SELECT AES_DECRYPT(UNHEX(필드명), '암호화 키') FROM 테이블명;
예제)
삽입
INSERT INTO Member
VALUES ('ID', hex(aes_encrypt('123123', 'key')))
조회
SELECT AES_DECRYPT(UNHEX(password), 'key') FROM Member;
위 방법이 안될 때
SELECT cast(AES_DECRYPT(UNHEX(password), 'key') as char(100)) FROM member where id='ID'
로그인??
SELECT * from member
where id = 'qqqq' and 123123 = (SELECT cast(AES_DECRYPT(UNHEX(password), 'dundung') as char(100)) FROM member where id='qqqq');
'DataBase' 카테고리의 다른 글
MySQL 날짜 포맷 변경 (0) | 2020.01.16 |
---|---|
Error Code: 1366. Incorrect string value: column (0) | 2019.11.13 |