Skip to content

Instantly share code, notes, and snippets.

@thihenos
Created July 7, 2018 03:38
Show Gist options
  • Save thihenos/28d5dc01ee1e8f6caecf40556a25cff6 to your computer and use it in GitHub Desktop.
Save thihenos/28d5dc01ee1e8f6caecf40556a25cff6 to your computer and use it in GitHub Desktop.
/*
* 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