Skip to content

Instantly share code, notes, and snippets.

View sagardere's full-sized avatar
🎯
Focusing

Dere Sagar sagardere

🎯
Focusing
View GitHub Profile
//Diffrent way to generate password in Nodejs
// 1
var CryptoJS = require("crypto-js");
var text = 'sagar';
var password = 'sagar';
var encrypted = CryptoJS.AES.encrypt(text, password);
encrypted = encrypted.toString();
console.log('@encrypted ' + encrypted);
class Animal{
constructor(name , height){
this.name = name;
this.height = height;
}
Hello(){
console.log("Hello from Animal");
}
}
//If you create the static methods in classes, then you call static methods without creating the class instances.
class Tasks{
static Addition(a , b){
return a+b;
}
static Subtraction(a , b){
return a-b;
}
var Cryptr = require('cryptr'),
cryptr = new Cryptr('secretKey');
var encryptedString = cryptr.encrypt('sagar'),
decryptedString = cryptr.decrypt(encryptedString);
console.log(encryptedString); // 0ed11b7de924ff2a81260fb5d44a954c
console.log(decryptedString); // sagar
var nodemailer = require('nodemailer');
//send mail using nodemailer via gmail service
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'yourEmail',
pass: 'yourPassword'
}
});