弱弱的- -!问题一下 我在我的SQL里,发里,字母 z 经过软件加密以后值为 6a9037n7ylaqouitzspoos86kw3n48我通过SQL2005 的函数,类似select right(sys.fn_VarBinToHexStr(hashbytes('MD5', 'z')),30)算出来对不上,问问大家这是怎么算出来的啊,还有能反算吗?
望 大家赐教,谢谢!
望 大家赐教,谢谢!
解决方案 »
- 请教MSDE问题
- 用ASP如何备份MSSQL?
- sqlserver数据库无时间字段怎么查询一个时间段数据记录
- 求助,关于BCP操作临时表的问题
- 我用“附加数据库”导入数据之后,dbo的登录名为空!
- a.mdf 700M,a_log.ldf 1.7G.怎么把a_log.ldf变成10M?
- 请教一个大家应该经常碰到的问题
- 帮忙看一下这个SQL语句有什么办法解决。
- 没有办法,只好提问了: 我使用了Update 语句,而且影响行数达10W行,现在我想还原到。。。。
- 怎样给别人回复的贴子加分————菜鸟问?????????????
- 如何让sql显示出给定的年的月份
- Server SQL 查询结果怎么样按自己的要求排序
create function sys.fn_varbintohexstr
(
@pbinin varbinary(max)
)
returns nvarchar(max)
as
begin
return sys.fn_varbintohexsubstring(1,@pbinin,1,0)
end
----------------------------------------------------------------
create function sys.fn_varbintohexsubstring (
@fsetprefix bit = 1 -- append '0x' to the output
,@pbinin varbinary(max) -- input binary stream
,@startoffset int = 1 -- starting offset
,@cbytesin int = 0 -- length of input to consider, 0 means total length
)
returns nvarchar(max)
as
begin
declare @pstrout nvarchar(max)
,@i int
,@firstnibble int
,@secondnibble int
,@tempint int
,@hexstring char(16) --
-- initialize and validate
--
if (@pbinin IS NOT NULL)
begin
select @i = 0
,@cbytesin = case when (@cbytesin > 0) then @cbytesin else DATALENGTH(@pbinin) end
,@pstrout = case when (@fsetprefix = 1) then N'0x' else N'' end
,@hexstring = '0123456789abcdef' if ( ((@cbytesin * 2) + 2 > 4000) or ((@cbytesin * 2) + 2 < 1) )
return NULL if ( ( @startoffset > DATALENGTH(@pbinin) ) or ( @startoffset < 1 ) )
return NULL --
-- adjust the length to process based on start offset and
-- total length
--
if ((DATALENGTH(@pbinin) - @startoffset + 1) < @cbytesin)
select @cbytesin = DATALENGTH(@pbinin) - @startoffset + 1
--
-- do for each byte
--
while (@i < @cbytesin)
begin
--
-- Each byte has two nibbles
-- which we convert to character
--
select @tempint = cast(substring(@pbinin, @i + @startoffset, 1) as int)
select @firstnibble = @tempint / 16
select @secondnibble = @tempint % 16 --
-- we need to do an explicit cast with substring
-- for proper string conversion.
--
select @pstrout = @pstrout +
cast(substring(@hexstring, (@firstnibble+1), 1) as nvarchar) +
cast(substring(@hexstring, (@secondnibble+1), 1) as nvarchar) select @i = @i + 1
end
end
-- All done
return @pstrout
end