티스토리 뷰
반응형
암호화에는 대칭형 암호화 비대칭형 암호화 2가지 방법이있다.
대칭형 암호화는 앞서 포스팅한 방법처럼 key가 존재하여 같은 key를 사용하면 복호화가 가능하다는 장점이 있다.
하지만 rainbowTable이 존재하여 보안적인 요소에는 취약하다. 주로 난독화할때 사용하면 될것같다.
비대칭형 암호화는 흔히들 소금을 뿌린다고 하는데 hash값을 섞어서 복호화를 할 수없게한다.
대부분의 민감한정보들 Password같은 경우는 비대칭형(비대칭키) 암호화를 사용해야한다.
암호화를 할 수 있는 여러가지 방법중 bcrypt 를 사용한 비대칭형 암호화를 사용하여 password를 암호화한 코드이다.
const Bcrypt = require("bcrypt");
const saltOrRounds = 10; //비대칭 암호화 횟수, 높을수록 보안성은 증가하지만 속도가 오래걸림
//암호화_복호화 불가능함! 동기로 작동 암호화된 값 반환
function encryptPassword(data) {
return Bcrypt.hashSync(data, saltOrRounds);
}
//비밀번호 비교 true false 반환
function comparePassword(beforeEncryptPwd, afterEncryptPwd) {
return Bcrypt.compareSync(beforeEncryptPwd, afterEncryptPwd);
}
module.exports = {
encryptPassword,
comparePassword,
};
공용함수로 만들어놓고 암호화가 필요할때마다 사용하면 편하게 사용할 수 있다.
반응형
'Server' 카테고리의 다른 글
[node.js] base 64 이미지 decode 및 저장 방법 (0) | 2022.05.04 |
---|---|
[Express] http로 접속시 https로 redirect (0) | 2022.05.03 |
[Express] session mySQL에 저장하기 (0) | 2022.05.03 |
[Express] schedule , 특정 시간 마다 이벤트 처리 (0) | 2021.11.12 |
[Express] request is not defined 해결법 (0) | 2021.09.13 |
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Procedure #mysql #mysql Procedure #mysql 반복문 #Procedure 반복문 #mysql insert 반복문
- 이미지 전송 # 이미지 업로드 #이미지 여러장 #이미지 여러장 업로드 #react 이미지 업로드 #react 이미지 여러장 업로드
- PDF #pdfkit
- node.js #node.js pdf만들기 #node.js pdfkit
- mysql date type
- BOJ #JS
- mysql date between # mysql date between 대소 비교 연산자
- AWS #인바운드 #SSH #인스턴스 연결
- Swal #sweetalert2 #alert #알림창 띄우기 #react swal
- docker # docker build # m1 docker build
- Express multer #Express File 저장 #node.js
- mysql date between performance
- ec2 instance connect is unable to connect to your instance. ensure your instance network settings are configured correctly for ec2 instance connect. for more information
- react #react-spinners #modal loading #overlay #로딩창 #react 로딩창 만들기
- supported: linux/amd64
- Pytorch #Yolov5 #Segementation
- linux/amd64/v2
- ERROR: failed to solve: no support for running processes with linux/amd64/v3 platform
- JavaScript #Programmers #lvl2 #프로그래머스 오픈채팅방 # 오픈채팅방 문제
- mysql date
- React filter #js Includes #React Filter includes
- react #img 전송
- node.js 파일 저장
- FormData #FormData 파일전송 #FormData append json # React FormData File #React FormData append Json
- excel 파일 만들기 #node.js #express excel 파일 만들기 #데이터 입력해서 excel 파일 만들기
- Mac docker.for.mac.host.internal
- reack-cookies #아이디 저장하기 #react 아이디 저장 #react cookie #리엑트 아이디 저장하기
- see ec2 instance connect prerequisites at https://docs.aws.amazon.com/awsec2/latest/userguide #인스턴스 연결 안됨
- docker mysql
- PoolCluster : Error: connect ECONNREFUSED 127.0.0.1:3306)
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함