密码加密问题?

CoolSailor 2003-04-01 04:48:09
大虾:
我的用户表有用户名和密码等字段,我想密码字段应该加密后存到用户表里。
哪位能够提供一个用sql写的加密和解密sp,算法简单还是复杂没关系。如果这点
分不够,可以再给。
...全文
68 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
CoolSailor 2003-04-02
  • 打赏
  • 举报
回复
多谢各位,我用c#提供的东东加密了。
每人10分
benxie 2003-04-02
  • 打赏
  • 举报
回复
我有VB的SQL加密,要吗?可以锱言给我。
j9988 2003-04-01
  • 打赏
  • 举报
回复
w_rose说得对。加密算法最好是不可逆的。
w_rose 2003-04-01
  • 打赏
  • 举报
回复
如果有“解密”的方法存在,那么这个东东就非常不可靠。
lngtying 2003-04-01
  • 打赏
  • 举报
回复
我的想法是:
把輸入的密碼字符逐個轉換asc码再加上一個數如4保存到資料庫,
用戶使用時把用戶輸入的密碼也按同樣的方法轉換asc码,再于資料庫中的密碼check.
happydreamer 2003-04-01
  • 打赏
  • 举报
回复
CREATE PROCEDURE sp_chgpwd(@userid char(4),@old char(30),@new char(30))
with recompile,encryption
AS
declare @tt0 int,@tt1 int,@tt2 int,@tt3 varchar(30),@ttkey int
declare @role tinyint

select @tt1=1
select @tt2=0
select @tt0=len(@userid)
while @tt1<=@tt0
begin
select @tt2=@tt2+ascii(substring(@userid,@tt1,1))
select @tt1=@tt1+1
end

select @ttkey=convert(int,(@tt2/@tt0))
select @tt3=''
select @tt0=len(@new)

select @tt1=1
while @tt1<=@tt0
begin
select @tt2=ascii(substring(@new,@tt1,1))^(@ttkey+@tt1)
if char(@tt2)="'"
select @tt3=@tt3+'$'
else
begin
select @tt3=@tt3+char(@tt2)
end
select @tt1=@tt1+1
end

update login set password=rtrim(ltrim(@tt3)) where lo_code=@userid

if @@trancount>0
commit tran



解密算法一样


declare @userid char(4)
declare @tt0 int,@tt1 int,@tt2 int,@tt3 varchar(30),@ttkey int
declare @role tinyint
declare @new char(30)

select @userid=1447
select @tt1=1
select @tt2=0
select @tt0=len(@userid)
while @tt1<=@tt0
begin
select @tt2=@tt2+ascii(substring(@userid,@tt1,1))
select @tt1=@tt1+1
end


select @new=(select password from td_login where lo_code=@userid)

select @ttkey=convert(int,(@tt2/@tt0))
select @tt3=''
select @tt0=len(@new)

select @tt1=1
while @tt1<=@tt0
begin
select @tt2=ascii(substring(@new,@tt1,1))^(@ttkey+@tt1)
--if char(@tt2)="'"
-- select @tt3=@tt3+'$'
--else
begin
select @tt3=@tt3+char(@tt2)

end
select @tt1=@tt1+1
end

select @tt3
happydreamer 2003-04-01
  • 打赏
  • 举报
回复


CREATE PROCEDURE sp_pwd(@userid char(4))
with recompile,encryption
AS

declare @tt0 int,@tt1 int,@tt2 int,@tt3 varchar(30),@ttkey int
declare @role tinyint
declare @new char(30)

select @tt1=1
select @tt2=0
select @tt0=len(@userid)
while @tt1<=@tt0
begin
select @tt2=@tt2+ascii(substring(@userid,@tt1,1))
select @tt1=@tt1+1
end


select @new=(select password字段 from login表 where lo_code=@userid)

select @ttkey=convert(int,(@tt2/@tt0))
select @tt3=''
select @tt0=len(@new)

select @tt1=1
while @tt1<=@tt0
begin
select @tt2=ascii(substring(@new,@tt1,1))^(@ttkey+@tt1)
--if char(@tt2)="'"
-- select @tt3=@tt3+'$'
--else
begin
select @tt3=@tt3+char(@tt2)

end
select @tt1=@tt1+1
end


update td_login set password=rtrim(ltrim(@tt3)) where lo_code=@userid

yoki 2003-04-01
  • 打赏
  • 举报
回复
加密方式:将每个字符串逆向排列,取其ASC码减当前位置值的字符。
比如:当前数据为:woshiladeng,则先逆向,即:gnedalihsow,然后分别取'g','n','e','d'...的asc码并加'1','2','3','4'将结果再转成字符。
yoki 2003-04-01
  • 打赏
  • 举报
回复
最简单的无非是将你要加密的字段与某个数异或再存进去,读的时候再异或一下
huejim 2003-04-01
  • 打赏
  • 举报
回复
建议用md5
CoolSailor 2003-04-01
  • 打赏
  • 举报
回复
前台加密一般用什么算法呢?请教?
caiyunxia 2003-04-01
  • 打赏
  • 举报
回复
up
CrazyFor 2003-04-01
  • 打赏
  • 举报
回复
在前台加密比较好。

22,210

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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