본문 바로가기

분류 전체보기41

Node.js 비밀번호 보안(Password Security) node에서 비밀번호를 암호화하기 위해 md5, sha256, pbkdf2 등의 모듈을 사용할 수 있습니다. 1. MD5(wiki 보러가기) - md5 hashing 알고리즘을 통해 데이터를 암호화합니다. (1) MD5 사용법 npm install md5 var md5 = require('md5'); var securePassword = md5('password'); 문제점인터넷에 검색만 해봐도 쉽게 Cracking이 가능한 문제점이 있습니다.- 이를 보완하기 위해 salt값을 추가하는 방법이 있습니다. (2) MD5 + salt값 추가 var md5 = require('md5'); var salt = '!%@#%asdg1613'; var securePassword = md5('password + sal.. 2017. 7. 6.
MongoDB를 통해 Node.js에서 간단한 REST API 구현 1. Model을 만든다.(=DTO or VO) models/user.jsmodels/user.js var mongoose = require('mongoose'); var Schema = mongoose.Schema; var userSchema = new Schema({ email: String, passwd: String, created_date: {type: Date, default: Date.now()} }); module.exports = mongoose.model('user', userSchema); 2.라우팅 파일 수정 routes/index.js routes/index.js 파일에 만들었던 User Model을 추가한다. 구현한 기능은 3가지 입니다. (1) POST /registMongoD.. 2017. 7. 6.
Express에서 Mongoose로 DB 연결 1. npm을 통해 mongoose 모듈 설치 npm install mongoose 2. 자바스크립트 작성 connection-test.jsvar mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/mydb'); var db = mongoose.connection; db.on('error', console.error.bind(console, 'connection error:')); db.once('open', function() { // we're connected! console.log('connected successfully'); }); 3. 실행 node connection-test.js 2017. 7. 6.
Window 32bit MongoDB 설치하기 1. MongoDB 다운로드 Linux와 Mac 운영체제와는 다르게 설치파일을 다운로드받아 설치합니다. MongoDB 다운로드 링크https://www.mongodb.com/download-center 64bit의 경우 바로 DOWNLOAD 버튼을 클릭하여 최신버전을 다운로드하면 됩니다. 하지만 3.4버전부터는 더 이상 32bit를 지원하지 않기 때문에 출처 [https://docs.mongodb.com/manual/installation/] 아래 경로로 이동해 .msi 확장자 파일을 다운로드 하여 설치합니다.https://www.mongodb.org/dl/win32/i386 2. DB path 생성 설치 후 cmd를 열어 MongoDB를 실행하기 전 db의 데이터들을 저장할 data 폴더를 C:\ 아래.. 2017. 7. 6.