Search code examples
c#httpwebrequestwebrequestnetworkcredentials

c# NetworkCredential and System.Net.WebRequest store crypted in code


I have to make web request with a distant server, and of course I have to authentify for each request. I have a System.Net.WebRequest and I fill it's Credentials with a NetworkCredential. The problem is, to initialize NetworkCredential I need to put in plain text in my code the credential informations.

new NetworkCredential("my username", "my pwd");

How can i declare my credentials informations crypted in my code (sha256)? The thing is, i understand how request generally crypt your informations before sending, and how server store you credential already crypted, so there must be a way for me to directly write crypted credential and "say" to NetworkCredential or WebRequest : "this username and pwd are already crypted", and the server will not try to crypt it before comparing with the one stored in the database.

I have been searching but couldn't find a way or a clue. Thanks in advance.


Solution

  • There was no "turn-around".

    The "solution" i'm using right now is, there nothing stored in code, when launching the API the client has to provide the user informations.