I am saving the credentails to the windows vault store using the credential manager API . But i need to keep it secure and also what is the maximum password limit length to do so.
Core Code to save and retrieve the credentails in the windows vault folder as below:
-
- public void SavePassword(string password)
- {
- try
- {
- using (var cred = new Credential())
- {
- cred.Password = password;
- cred.Target = PasswordName;
- cred.Type = CredentialType.Generic;
- cred.PersistanceType = PersistanceType.LocalComputer;
- cred.Save();
- }
- }
- catch(Exception ex)
- {
- }
- }
-
- public string GetPassword()
- {
- try {
- using (var cred = new Credential())
- {
- cred.Target = PasswordName;
- cred.Load();
- return cred.Password;
- }
- }
- catch (Exception ex)
- {
- }
- return "";
- }