Click here to Skip to main content
13,734,927 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
I am getting exception while passing a long string to save to the windows vault folder using c# and Credential Manager API. Else it is getting saved successfully to the vault.

Exception coming is
Specified argument was out of the range of valid values.

Parameter name: The password has exceeded 512 bytes.
&

password string passed is "TERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRTGVBFXDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDTREEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEECFGBBCVBDRFGDXFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXRETWEREWRW3ERWERWRWRWRRRRRRRRRRRRRRRRRRRRRFDSFFFSDFSFSFSFDSFDDFSFSFSFGRWERWREWRWRWRDXVGFDGFDGFDGFDGDGDFGDGDGDREWRWREWRERRWREWREWRDXVCXBCVVVVVVVVVVVVVVREWRWERRRRRRRRRRREWRWRWREWR"

What I have tried:

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)
           {

           }

       }
Posted 18-May-18 1:31am
Updated 18-May-18 1:42am
Comments
GKP1992 18-May-18 7:39am
   
Just me or the password string goes on and on in a single line overflowing the CP page?Chrome by the way.
Richard Deeming 18-May-18 9:40am
   
It's not just you. The browser can't find an obvious place to break the line, so without word-wrap: break-word; on the containing <div>, it won't wrap onto a new line.
GKP1992 21-May-18 0:22am
   
Why do you need to have such a long password anyway? Can a user ever remember that?

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Parameter name: The password has exceeded 512 bytes.


Your password is 600 bytes long and the maximum allowed is 512.
  Permalink  
Comments
ranio 4-Jun-18 3:11am
   
So what is the solution for saving public key content length greater than 512 bytes long. Can I split the same say 500 bytes each and then save to the vault and retrieve concatenating the splited vault values altogether.

Is this split option possible or Is there any better option to do the same ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web01-2016 | 2.8.180920.1 | Last Updated 18 May 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100