Created
July 7, 2018 03:38
-
-
Save thihenos/28d5dc01ee1e8f6caecf40556a25cff6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Sync all tables to database | |
*/ | |
db.sequelize.sync({force:true}).then(function(){ | |
console.log('DB Connection - OK'); | |
let crypto = require('crypto'); | |
//Lib for crypting strings | |
let crypto = require('crypto'); | |
//Creating my cipher, by using the key REPLACE_YOUR_KEY_HERE | |
let cipher = crypto.createCipher('aes192','REPLACE_YOUR_KEY_HERE'); | |
//Crypting ADM string | |
let crypted = cipher.update('ADM','utf8','hex'); | |
crypted += cipher.final('hex'); | |
if(crypted){ | |
//Creating ADM user | |
db.User.create({username: 'ADM', password: crypted}).then(function() { | |
console.log('ADM user inserted'); | |
}, function (error) { | |
console.log(error);res.sendStatus(500); | |
}); | |
}else{ | |
console.log('Something went wrong with crypting the password :('); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment