public void ProduceUniqueSALTs() { var salt1 = EncryptPassword.CreateSALT(); var salt2 = EncryptPassword.CreateSALT(); Assert.NotEqual(salt1, salt2); }
static void Main(string[] args) { var credentialsDAO = new CredentialsDAO(); var allCredentials = credentialsDAO.FetchAllRecords(); foreach (var credential in allCredentials) { var salt = EncryptPassword.CreateSALT(); Console.WriteLine($"{credential.Password} + " + $"{Convert.ToBase64String(EncryptPassword.CreateHASH(credential.Password, salt))} + " + $"{salt}"); } }
public IActionResult AddCredentialsAsAdmin([FromForm] Credentials newCredentials) { newCredentials.SALT = EncryptPassword.CreateSALT(); string hashedPassword = Convert.ToBase64String(EncryptPassword.CreateHASH(newCredentials.Password, newCredentials.SALT)); newCredentials.Password = hashedPassword; var id = _credentialsDAO.AddRecordReturningID(newCredentials); switch (newCredentials.Role) { case Role.Admin: return(RedirectToAction("Index", "Admin", new { id })); case Role.Mentor: return(RedirectToAction("Create", "Mentor", new { id })); case Role.Student: return(RedirectToAction("Create", "Student", new { id })); default: return(View()); } }