MD5算法的T-SQL实现(FOR SQL2000)(一)
时间:2007-11-09 来源:不详 作者:迈克DB
DROP FUNCTION [dbo].[MD5_F]
GO
/*****************************************************************************
* Name: MD5_F
* Description: MD5_F
*****************************************************************************/
CREATE FUNCTION dbo.MD5_F(
@x INT
,@y INT
,@z INT
)
RETURNS INT
WITH ENCRYPTION
AS
BEGIN
RETURN((@x & @y) | ((~@x) & @z))
END
GO
IF EXISTS(SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[MD5_G]') AND xtype IN(N'FN', N'IF', N'TF'))
DROP FUNCTION [dbo].[MD5_G]
GO
/*****************************************************************************
* Name: MD5_G
* Description: MD5_G
*****************************************************************************/
CREATE FUNCTION dbo.MD5_G(
@x INT
,@y INT
,@z INT
)
RETURNS INT
WITH ENCRYPTION
AS
BEGIN
RETURN((@x & @z) | (@y & (~@z)))
END 织梦好,好织梦
GO
IF EXISTS(SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[MD5_H]') AND xtype IN(N'FN', N'IF', N'TF'))
DROP FUNCTION [dbo].[MD5_H]
GO
/*****************************************************************************
* Name: MD5_H
* Description: MD5_H
*****************************************************************************/
CREATE FUNCTION dbo.MD5_H(
@x INT
,@y INT
,@z INT
)
RETURNS INT
WITH ENCRYPTION
AS
BEGIN
RETURN(@x ^ @y ^ @z)
END
GO
IF EXISTS(SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[MD5_I]') AND xtype IN(N'FN', N'IF', N'TF'))
DROP FUNCTION [dbo].[MD5_I]
GO
/*****************************************************************************
* Name: MD5_I
* Description: MD5_I
*****************************************************************************/
CREATE FUNCTION dbo.MD5_I(
@x INT
,@y INT
,@z INT 织梦好,好织梦
)
RETURNS INT
WITH ENCRYPTION
AS
BEGIN
RETURN(@y ^ (@x | (~@z)))
END
GO
IF EXISTS(SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[MD5_FF]') AND xtype IN(N'FN', N'IF', N'TF'))
DROP FUNCTION [dbo].[MD5_FF]
GO
/*****************************************************************************
* Name: MD5_FF
* Description: MD5_FF
*****************************************************************************/
CREATE FUNCTION dbo.MD5_FF(
@a INT
,@b INT
,@c INT
,@d INT
,@x INT
,@s INT
,@ac INT
)
RETURNS INT
WITH ENCRYPTION
AS
BEGIN
SET @a = dbo.MD5_AddUnsigned(@a, dbo.MD5_AddUnsigned(dbo.MD5_AddUnsigned(dbo.MD5_F(@b, @c, @d), @x), @ac))
SET @a = dbo.MD5_RotateLeft(@a, @s)
SET @a = dbo.MD5_AddUnsigned(@a, @b)
RETURN(@a)
END
GO
IF EXISTS(SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[MD5_GG]') AND xtype IN(N'FN', N'IF', N'TF'))
文章评论
共有位Admini5网友发表了评论 查看完整内容