程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SqlServer數據庫 >> 關於SqlServer >> MD5算法的TSQL實現(FOR SQL2000)(一)

MD5算法的TSQL實現(FOR SQL2000)(一)

編輯:關於SqlServer
)(一)。 /*****************************************************************************
* Name: T-SQL MD5算法實現
* Author: Rambo Qian
* Create Date: 2003-04-10
* Last ModifIEd by: Rambo Qian
* Last Update Date: 2003-04-16
* Version: V1.0.00
*****************************************************************************/
GO

IF EXISTS(SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[MD5_m_OnBits]') AND xtype IN(N'FN', N'IF', N'TF'))
  DROP FUNCTION [dbo].[MD5_m_OnBits]
GO
/*****************************************************************************
* Name: MD5_m_OnBits
* Description: 常數組
*****************************************************************************/
CREATE FUNCTION dbo.MD5_m_OnBits(
  @i  TINYINT
)
RETURNS INT
WITH ENCRYPTION
AS
BEGIN
  DECLARE @iRes  INT
  SELECT @iRes =
    CASE @i
      WHEN 0 THEN 1      -- 00000000000000000000000000000001
      WHEN 1 THEN 3      -- 00000000000000000000000000000011
      WHEN 2 THEN 7      -- 00000000000000000000000000000111
      WHEN 3 THEN 15      -- 00000000000000000000000000001111
      WHEN 4 THEN 31      -- 00000000000000000000000000011111
      WHEN 5 THEN 63      -- 00000000000000000000000000111111
      WHEN 6 THEN 127     -- 00000000000000000000000001111111
      WHEN 7 THEN 255     -- 00000000000000000000000011111111
      WHEN 8 THEN 511     -- 00000000000000000000000111111111
      WHEN 9 THEN 1023     -- 00000000000000000000001111111111
      WHEN 10 THEN 2047     -- 00000000000000000000011111111111
      WHEN 11 THEN 4095     -- 00000000000000000000111111111111
      WHEN 12 THEN 8191     -- 00000000000000000001111111111111
      WHEN 13 THEN 16383    -- 00000000000000000011111111111111
      WHEN 14 THEN 32767    -- 00000000000000000111111111111111
      WHEN 15 THEN 65535    -- 00000000000000001111111111111111
      WHEN 16 THEN 131071    -- 00000000000000011111111111111111
      WHEN 17 THEN 262143    -- 00000000000000111111111111111
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved