• 数据库数据加密与解密


    MVC的练习之旅,将要进入另一个阶段了,将增加会员功能。在进入之前,一些准备工作需要做的。一步一个脚印吧。设计会员功能,其中密码字段,Insus.NET想对它进行加密。就因这个加密,还得花上一些时间来整理。
    Insus.NET参考MSDN网站,列出数据库加密解密例子(以下是在SQL Server 2012进行):

    --创建数据库主密钥
    CREATE MASTER KEY ENCRYPTION BY PASSWORD ='Pass#Tutorial#word'
    GO
    --创建证书
    CREATE CERTIFICATE PasswordCert 
    with SUBJECT = 'Member Password Certificate'
    GO
    --创建非对称密钥
    CREATE ASYMMETRIC KEY PasswordAsymmetric
        WITH ALGORITHM = RSA_2048 --{ RSA_512 | RSA_1024 | RSA_2048 } 
        ENCRYPTION BY PASSWORD = 'Pass#Tutorial#word'; 
    GO
    --创建对称密钥
    CREATE SYMMETRIC KEY PasswordSymmetric
        WITH ALGORITHM = AES_256 --{ AES_128 | AES_192 | AES_256 | TRIPLE_DES_3KEY }
        ENCRYPTION BY PASSWORD = 'Pass#Tutorial#word';
    GO
    --由证书加密对称密钥
    CREATE SYMMETRIC KEY SymmetricByCert
        WITH ALGORITHM = AES_256
        ENCRYPTION BY CERTIFICATE PasswordCert;
    GO
    --由对称密钥加密对称密钥
    OPEN SYMMETRIC KEY PasswordSymmetric
        DECRYPTION BY PASSWORD='Pass#Tutorial#word'
    
    CREATE SYMMETRIC KEY SymmetricBySy
        WITH ALGORITHM = AES_256
        ENCRYPTION BY SYMMETRIC KEY PasswordSymmetric;
    GO
    --由非对称密钥加密对称密钥
    CREATE SYMMETRIC KEY SymmetricByAsy
        WITH ALGORITHM = AES_256
        ENCRYPTION BY ASYMMETRIC KEY PasswordAsymmetric;
    GO

     

    创建之后,会要相应的数据库之下,显示如下:

  • 相关阅读:
    路由器DHCP 动态主机配置
    nat转换
    静态路由的实验
    不同vlan之间的相互访问
    IP的包头格式什么?请分析每个字段的含义
    IP地址的分类
    关于对JSON.parse()与JSON.stringify()的理解
    Ajax工作原理
    关于css伪类
    开发 | 如何在微信小程序的页面间传递数据?
  • 原文地址:https://www.cnblogs.com/insus/p/3434735.html
Copyright © 2020-2023  润新知