Last active
November 4, 2019 11:27
-
-
Save trishantpahwa/aa3e7888c32eb37dc0c8ae424e8a8e83 to your computer and use it in GitHub Desktop.
Password Oscillations
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
const readline = require('readline'); | |
var passwordsLog = { }; | |
function addLoginField(loginField, password) { | |
passwordsLog[loginField] = { }; | |
var date = new Date(); | |
date.toLocaleDateString("en-IN"); | |
passwordsLog[loginField].password = date; | |
} | |
function addChangedPasswordDate(loginField, password) { | |
var date = new Date(); | |
date.toLocaleDateString("en-IN"); | |
passwordsLog[loginField].password = date; | |
} | |
function getChangedPasswordDateLog(loginField) { | |
return passwordsLog[loginField]; | |
} | |
function getChangedPasswordDate(loginField, password) { | |
return passwordsLog[loginField].password; | |
} | |
function take_input(callback) { | |
var r1 = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
questionString = ''; | |
r1.question(questionString, function(answer) { | |
callback(answer); | |
r1.close() | |
}); | |
} | |
while(true) { | |
console.log("> 1. Add login field and password."); | |
console.log("> 2. Add changed password date."); | |
console.log("> 3. Get changed password date log."); | |
console.log("> 4. Get changed password date."); | |
console.log("> 5. Close Script."); | |
var choice = raw_input("Enter choice: "); | |
if(choice == 1) { | |
var loginField = take_input(); | |
var password = take_input(): | |
addLoginField(loginField, password) { | |
} | |
if(choice == 2) { | |
var loginField = take_input(); | |
var password = take_input(); | |
addChangedPasswordDate(loginField, password); | |
} | |
if(choice == 3) { | |
var loginField = take_input(); | |
var password = take_input(); | |
var changedPasswordDateLog = getChangedPasswordDateLog(loginField, password); | |
console.log(changedPasswordDateLog); | |
} | |
if(choice == 4) { | |
var loginField = take_input(); | |
var password = take_input(); | |
var changedPasswordDate = getChangedPasswordDate(loginField, password); | |
console.log(changedPasswordDate); | |
} | |
if(choice == 5) { | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment