简体   繁体   English

c# NetworkCredential 和 System.Net.WebRequest 存储在代码中加密

[英]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.我必须使用远程服务器发出 Web 请求,当然我必须对每个请求进行身份验证。 I have a System.Net.WebRequest and I fill it's Credentials with a NetworkCredential.我有一个 System.Net.WebRequest,我用 NetworkCredential 填充它的 Credentials。 The problem is, to initialize NetworkCredential I need to put in plain text in my code the credential informations.问题是,要初始化 NetworkCredential,我需要在我的代码中以纯文本形式放入凭证信息。

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

How can i declare my credentials informations crypted in my code (sha256)?如何声明在我的代码 (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.问题是,我了解请求在发送之前通常如何加密您的信息,以及服务器如何存储您已经加密的凭证,所以必须有一种方法让我直接写入加密凭证并“说”到 NetworkCredential 或 WebRequest :“这个用户名和pwd 已经被加密”,并且服务器在与存储在数据库中的密码进行比较之前不会尝试对其进行加密。

I have been searching but couldn't find a way or a clue.我一直在寻找,但找不到方法或线索。 Thanks in advance.提前致谢。

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.我现在使用的“解决方案”是,代码中没有存储任何内容,在启动 API 时,客户端必须提供用户信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM