加密web.conf中的连接字符串 [英] encrypt connection string in web.conf

查看:81
本文介绍了加密web.conf中的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在web.conf的连接字符串中加密凭据的最常用和最实用的方法是什么。我们将非常感谢示例代码。

what is the most common and practical way to encrypt credentials in connection strings of web.conf. A sample code will be appreciated.

推荐答案

加密连接字符串的最简单方法是使用Base64编码。但这不是真正的加密:(。

A simplest way to encrypt your connection string is use Base64 encoding. But this is not real encryption:(.

 

static public string EncodeToBase64(string toEncode)
 {
  byte[] toEncodeAsBytes
   = System.Text.ASCIIEncoding.ASCII.GetBytes(toEncode);
  string returnValue
   = System.Convert.ToBase64String(toEncodeAsBytes);
  return returnValue;
 }
 static public string DecodeFromBase64(string encodedData)
 {
  byte[] encodedDataAsBytes
   = System.Convert.FromBase64String(encodedData);
  string returnValue =
   System.Text.ASCIIEncoding.ASCII.GetString(encodedDataAsBytes);
  return returnValue;
 }

  ;

如果您想使用真正的加密,您可以使用各种.NET Framework加密提供程序。例如TripleDES。

If you want use real encryption you can use various of .NET Framework encryption providers. For example TripleDES.

 

亲切的问候,格里戈里


这篇关于加密web.conf中的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆