!!!!!如何查看已加密的存储过程!!!!!!

cjlong 2002-09-11 09:37:50
请问1、如何查看已加密的存储过程
2、存储过程如何加密
...全文
30 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
duckcn 2002-09-11
  • 打赏
  • 举报
回复
http://www.csdn.net/Expert/TopicView1.asp?id=994598
cjlong 2002-09-11
  • 打赏
  • 举报
回复
我主要是想知道解密的方法

楼上的可能不行,我是2000
freezwy 2002-09-11
  • 打赏
  • 举报
回复
建议搜索以前的帖子,有高人都解决了,并帖有代码。
-----------------------------
加密:
USE pubs
GO
CREATE PROCEDURE encrypt_this
WITH ENCRYPTION
AS
SELECT *
FROM authors
GO
连自己也看不到了. 要先备份
-----------
解密:
试试下面的,从别处拿过来的

Here is the code for SQL 6.5

/************************************************/
/* REVISED REC'D 5/21/98 */
/* sp_decrypt_object Tom Sager 01/26/98 */
/* */
/* Decrypts objects (views, procedures & trigs) */
/* created with the WITH ENCRYPTION option. */
/* */
/* Uses the encrypt() built-in function to find */
/* a plaintext string that encrypts to the same */
/* value as stored in the text column of the */
/* syscomments table. */
/* */
/************************************************/
create proc sp_decrypt_object
(@objname varchar(30))
WITH ENCRYPTION
as

SET NOCOUNT ON

declare @errmsg varchar(80)
declare @encrtext varchar(255)
declare @decrtext varchar(255)
declare @testtext varchar(255)
declare @printline varchar(255)
declare @textlen int
declare @lup int
declare @match char(1)
declare @testchar smallint
declare @begblk smallint
declare @endblk smallint

if (select count(*)
from sysobjects
where name = @objname) = 0
begin
select @errmsg = 'Object '
+@objname
+' not found in database '
+DB_NAME()
print @errmsg
return 1
end

if (select count(*) from sysobjects t1,
syscomments t2
where t1.name = @objname
and t1.id = t2.id
and t2.texttype & 4 != 0) = 0
begin
select @errmsg = 'Object '
+@objname
+' is not encrypted in database '
+DB_NAME()
print @errmsg
return 1
end

DECLARE comments_cursor CURSOR for
select t1.text
from syscomments t1,
sysobjects t2
where t1.id = t2.id
and t2.name = @objname
order by t1.colid

OPEN comments_cursor

FETCH NEXT FROM comments_cursor
INTO @encrtext

WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
select @decrtext = REPLICATE(' ', 255)
select @textlen = DATALENGTH(@encrtext)
select @lup = 1
select @match = 'n'
while (@lup <= @textlen)
begin
select @testchar = 0
select @match = 'n'
while (@match = 'n')
begin
select @decrtext =
STUFF(@decrtext,@lup,1,CHAR(@testchar))
select @testtext = encrypt(@decrtext)
if ASCII(SUBSTRING(@testtext,@lup,1)) =
ASCII(SUBSTRING(@encrtext,@lup,1))
begin
select @match = 'y'
end
select @testchar = @testchar + 1
if (@testchar > 255)
begin
print 'Error...no match found'
return 1
end
end
select @lup = @lup + 1
end
select @begblk = 1
select @endblk = 1
while (@endblk <= @textlen)
begin
if (substring(@decrtext,@endblk,1) = 0x0a)
begin
select @printline = @printline +
SUBSTRING(@decrtext
,@begblk
,@endblk-@begblk+1)
print @printline
select @begblk = @endblk + 1
select @endblk = @begblk
select @printline = NULL
end
select @endblk = @endblk + 1
end
select @printline = @printline +
SUBSTRING(@decrtext
,@begblk
,@endblk-@begblk+1)
END
FETCH NEXT FROM comments_cursor INTO @encrtext
END
print @printline
CLOSE comments_cursor

DEALLOCATE comments_cursor
GO

34,575

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧