Node Typescript에서 패스워드
https://sir.kr/so_restful/16
import를 하는 방법을 몰라서 헤멨네요
패스워드 체크하는 것도 안 적어놔서 모르겠네요. atob를 썼던 것 같은데, 지금 해보니 없어도 되네요.
옛날 코드를 아무리 찾아도 없어서, 그냥 구현했는데,
고수님들 보시고 알려주세요.
[code]
import * as btoa from 'btoa';
import * as crypto from 'crypto';
import * as pbkdf2 from 'pbkdf2';
const dkLen = 24;
const iterations = 12000;
const algorithm = 'sha256';
const salt = btoa(crypto.randomBytes(24));
var derivedKey = btoa(pbkdf2.pbkdf2Sync(this.mbPassword, salt, iterations, dkLen, algorithm));
mb_psassword = algorithm + ':' + iterations + ':' + salt + ':' + derivedKey;
[/code]
[code]
const dkLen = 24;
const [algorithm, iterations, salt, derivedKey] = mb_password.split(':');
const newDerivedKey = btoa(pbkdf2.pbkdf2Sync(attempt, salt, Number(iterations), dkLen, algorithm));
if(newDerivedKey === derivedKey) {
return true;
}
return false;
[/code]
> mb_password에 저장된 4개의 필드를 읽어옴
> 들어온 패스워드(in_password)를 사용해서 새로운 키를 만듬.
> mb_password에 있는 키와 새로 만든 키가 같으면 성공, 틀리면 실패
게시판 목록
RESTful
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 98 |
|
2개월 전 | 14 | |
| 97 |
|
3개월 전 | 19 | |
| 96 | 8개월 전 | 167 | ||
| 95 | 1년 전 | 341 | ||
| 94 | 2년 전 | 759 | ||
| 93 | 2년 전 | 764 | ||
| 92 | 2년 전 | 507 | ||
| 91 | 2년 전 | 645 | ||
| 90 |
jihan6?
|
2년 전 | 557 | |
| 89 |
jihan6?
|
2년 전 | 546 | |
| 88 |
jihan6?
|
2년 전 | 1599 | |
| 87 | 2년 전 | 895 | ||
| 86 | 2년 전 | 739 | ||
| 85 | 2년 전 | 1001 | ||
| 84 | 2년 전 | 2701 | ||
| 83 |
jihan006
|
2년 전 | 535 | |
| 82 |
jihan006
|
2년 전 | 839 | |
| 81 |
|
2년 전 | 694 | |
| 80 | 3년 전 | 1309 | ||
| 79 | 4년 전 | 984 | ||
| 78 | 4년 전 | 1070 | ||
| 77 | 4년 전 | 1464 | ||
| 76 | 4년 전 | 1297 | ||
| 75 | 4년 전 | 1688 | ||
| 74 | 4년 전 | 1640 | ||
| 73 | 4년 전 | 1797 | ||
| 72 | 4년 전 | 1490 | ||
| 71 | 4년 전 | 1401 | ||
| 70 | 4년 전 | 1528 | ||
| 69 | 4년 전 | 1564 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기