1. pgcrypto 설치
[root@localhost smoh]# yum install postgresql-contrib
2. 암호화
CREATE EXTENSION pgcrypto;
SELECT CRYPT('12345', GEN_SALT('md5'));
3. 검증
SELECT id FROM members WHERE id = 'id01' AND password = CRYPT('12345', password);
4. 전체 예시
CREATE EXTENSION pgcrypto;
DROP TABLE IF EXISTS members;
CREATE TABLE members (
id TEXT PRIMARY KEY,
password TEXT
);
INSERT INTO members(id, password) VALUES ('id01', CRYPT('12345', GEN_SALT('md5')));
SELECT * FROM members;
--SELECT id FROM members WHERE id = 'id01' AND password = CRYPT('12345', password);
반응형
'Programming > Databse' 카테고리의 다른 글
[Database] ORM (Object Relational Mapping) (0) | 2017.06.26 |
---|---|
[Database] Stored Procedure (0) | 2017.06.26 |
[PostgreSql] 상속(Inheritance) (0) | 2017.06.15 |
[PostgreSql] 트랜잭션(Transaction) (0) | 2017.06.15 |
[PostgreSql] 제약조건(Constraint) 설정, 제거 (0) | 2017.06.15 |