zoukankan      html  css  js  c++  java
  • 教你怎樣實現SQL密文加密,不可反編譯

    use Tempdb

    go

    if object_ID ( 'fn_ACITEncryption' ) is not null

        drop function fn_ACITEncryption

    go

    create function fn_ACITEncryption

    (

        @Str nvarchar ( 4000), -- 加密的字符串

        @Flag bit = 1, --1 、加密 0 、解密

        @Key nvarchar ( 50) -- 密文

    )

    returns nvarchar ( 4000) -- 這里可轉換成二進制

    with Encryption

    as

    begin

    Declare @LenStr int , @i int , @Str2 nvarchar ( 4000), @Split nvarchar ( 2), @LenKey int

    select @Str= @Str+ 'A' , @LenStr= len ( @Str), @i= 1, @Str2= '' , @LenKey= Len ( @Key+ 'A' )- 1

    while @i< @LenStr

            select     @Split= substring ( @Str, @i, 1),

                    @Split= nchar (( unicode ( @Split)+ case @Flag    when 1 then unicode ( substring ( @Key+ 'A' , @i% @LenKey+ 1, 1))- 1                                               

                                                        when 0 then 65535- unicode ( substring ( @Key+ 'A' , @i% @LenKey+ 1, 1))

                                                        else 0 end )% 65535+ cast ( @Flag as int )),

                     @Str2= @Str2+ @Split, @i= @i+ 1

    return @Str2

     

    end

    go

    select dbo. fn_ACITEncryption( N'Roy' , 1, '123' ) as 加密后字符串

     

    /*

    加密后字符串

    ------------------------------

    (1 個資料列受到影響 )

     

    */

    select dbo. fn_ACITEncryption( N, 0, '123' ) as 解密后字符串

    /*

    解密后字符串

    --------------------------

    Roy

     

    (1 個資料列受到影響 )

    */

  • 相关阅读:
    Spring Boot Sample 033之swagger3.0
    Spring Boot Sample 025之spring-boot-security-oauth2
    Spring Boot Sample 024之spring-boot-data-influxdb
    docker 安装redis /mysql/rabbitmq
    发布视频文件,并配置vtt格式的字幕文件
    Windows控制台用copy命令合并二进制文件
    Solaris修改IP地址
    为java程序配置网络访问代理
    apache2 httpd.conf 反向代理设置实例
    Apache配置正向代理与反向代理
  • 原文地址:https://www.cnblogs.com/Roy_88/p/5463087.html
Copyright © 2011-2022 走看看