加密存储

更新时间:2023-04-19 01:19:26 阅读: 评论:0


2023年4月19日发(作者:全球通套餐介绍)sql存储过程的加密解密
20070616 星期六 下午 01:38
加密:
CREATE PROCEDURE encrypt_this
WITH ENCRYPTION //改动的就这里。
AS
SELECT *
FROM authors
GO
解密麻烦了。比较长。
CREATE PROCEDURE sp_decrypt(@objectName varchar(50))
AS
begin
t nocount on
--CSDNj9988 copyright:2004.04.15
--V3.1
--破解字节不受限制,适用于SQLSERVER2000存储过程,函数,视图,触发器
--修正上一版视图触发器不能正确解密错误
--发现有错,请E_MAILCSDNj9988@
begin tran
declare @objectname1 varchar(100),@orgvarbin varbinary(8000)
declare @sql1 nvarchar(4000),@sql2 varchar(8000),@sql3
nvarchar(4000),@sql4 nvarchar(4000)
DECLARE @OrigSpText1 nvarchar(4000), @OrigSpText2 nvarchar(4000) ,
@OrigSpText3 nvarchar(4000), @resultsp nvarchar(4000)
declare @i int,@status int,@type varchar(10),@parentid int
declare @colid int,@n int,@q int,@j int,@k int,@encrypted int,@number int
lect @type=xtype,@parentid=parent_obj from sysobjects where
id=object_id(@ObjectName)

create table #temp(number int,colid int,ctext varbinary(8000),encrypted
int,status int)
inrt #temp SELECT number,colid,ctext,encrypted,status FROM
syscomments WHERE id = object_id(@objectName)
lect @number=max(number) from #temp
t @k=0

while @k<=@number
begin
if exists(lect 1 from syscomments where id=object_id(卧室摆放风水 @objectname) and

number=@k)
begin
if @type='P'
t @sql1=(ca when @number>1 then 'ALTER PROCEDURE '+ @objectName
+';'+rtrim(@k)+' WITH ENCRYPTION AS '
el 'ALTER PROCEDURE '+ @objectName+' WITH ENCRYPTION AS '
end)
if @type='TR'
begin
declare @parent_obj varchar(255),@tr_艺术类大学 parent_xtype varchar(10)
lect @parent_obj=parent_obj from sysobjects where
id=object_id(@objectName)
lect @tr_parent_xtype=xtype from sysobjects where id=@parent_obj
if @tr_parent_xtype='V'
begin
t @sql1='ALTER TRIGGER '+@objectname+' ON '+OBJECT_NAME(@parentid)+'
WITH ENCRYPTION INSTERD OF INSERT顾城诗歌 AS PRINT 1 '
end
el
begin
t @sql1='ALTER TRIGGER '+@objectname+' ON '+OBJECT_NAME(@parentid)+'
WITH ENCRYPTION FOR INSERT AS PRINT 1 '
end

end
if @type='FN' or @type='TF' or @type='IF'
t @sql1=(ca @type when 'TF' then
'ALTER FUNCTION '+ @objectName+'(@a char(1)) returns @b table(a
varchar(10)) with encryption as begin inrt @b lect @a return耶稣传 end '
when 'FN' then
'ALTER FUNCTION '+ @objectName+'(@a char(1)) returns char(1) with
encryption as begin return @a end'
when 'IF' then
'ALTER FUNCTION '+ @objectName+'(@a char(1)) returns table with
encryption as return lect @a as a'
end)

if @type='V'
t @sql1='ALTER VIEW '+@objectname+' WITH ENCRYPTION AS SELECT 1 as f'

t @q=len(@s手干燥粗糙怎么办 ql1)
t @sql1=@sql1+REPLICATE('-',4000-@q)
lect @sql2=REPLICATE('-',8000)
t @sql3='exec(@sql1'

lect @colid=max(colid) from #temp where number=@k
t @n=1
while @n<=CEILING(1.0*(@colid-1)/2) and len(@sQL3)<=3996
begin
t @sql3=@sql3+'+@'
t @n=@n+1
end
t @sql3=@sql3+')'
exec sp_executesql @sql3,N'@Sql1 nvarchar(4000),@
varchar(8000)',@sql1=@sql1,@=@sql2

end
t @k=@k+1
end

t @k=0
while @k<=@number
begin
if exists(lect 1 from syscomments where id=object_id(@objectname) and
number=@k)
begin
lect @colid=max(colid) from #temp where number=@k
t @n=1

while @n<=@colid
begin 英语地图
lect @OrigSpText1=ctext,@encrypted=encrypted,@status=status FROM
#temp WHERE colid=@n and number=@k

SET @OrigSpText3=(SELECT ctext FROM syscomments WHERE
id=object_id(@objectName) and colid=@n and number=@k)
if @n=1
begin
if @type='P'
SET @OrigSpText2=(ca when @number>1 then 'CREATE PROCEDURE '+
@objectName +';'+rtrim(@k)+' WITH ENCRYPTION AS '
el 'CREATE PROCEDURE '+ @objectName +' WITH ENCRYPTION AS '
end)


if @type='FN' or @type='TF' or @type='IF'
SET @OrigSpText2=(ca @type when 'TF' then
'CREATE FUNCTION '+ @objectName+'(@a char(1)) returns @b table(a
varchar(10)) with encryption as begin inrt @b lect @a return end '

when 'FN' then
'CREATE FUNCTION '+ @objectName+'(@a char(1)) returns char(1) with
encryption as begin return @a end'
when 'IF' then
'CREATE FUNCTION '+ @objectName+'(@a char(1白芝麻的功效与作用 )) retu搞笑日记 rns table with
encryption as return lect @a as a'
end)

if @type='TR'
begin

if @tr_parent_xtype='V'
begin
t @OrigSpText2='CREATE TRIGGER '+@objectname+' ON
'+OBJECT_NAME(@parentid)+' WITH ENCRYPTION INSTEAD OF INSERT AS PRINT 1
'
end
el
begin
t @OrigSpText2='CREATE TRIGGER '+@objectname+' ON
'+OBJECT_NAME(@parentid)+' WITH ENCRYPTION FOR INSERT AS PRINT 1 '
end
end

if @type='V'
t @OrigSpText2='CREATE VIEW '+@objectname+' WITH ENCRYPTION AS SELECT
1 as f'

t @q=4000-len(@OrigSpText2)
t @OrigSpText2=@OrigSpText2+REPLICATE('-',@q)
end
el
begin
SET @OrigSpText2=REPLICATE('-', 4000)
end
SET @i=1

SET @resultsp = replicate(N'A', (datalength(@OrigSpText1) / 2))

WHILE @i<=datalength(@OrigSpText1)/2
BEGIN

SET @resultsp = stuff(@resultsp, @i, 1,
NCHAR(UNICODE(substring(@OrigSpText1, @i, 1)) ^

(UNICODE(substring(@OrigSpText2, @i, 1)) ^
UNICODE(substring(@OrigSpText3, @i, 1)))))
SET @i=@i+1
END
t @orgvarbin=cast(@OrigSpText1 as varbinary(8000))
t @resultsp=(ca when @encrypted=1
t中华民族大团结 hen @resultsp
el convert(nvarchar(4000),ca when @status&2=2 then
uncompress(@orgvarbin) el @orgvarbin end)
end)
print @resultsp

t @n=@n+1

end

end
t @k=@k+1
end

drop table #temp
rollback tran
end



本文发布于:2023-04-19 01:19:26,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/503020.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

上一篇:任务书怎么写
下一篇:散文欣赏
标签:加密存储
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图