Generate MD5 hash string with T-SQL

后端 未结 9 1951
自闭症患者
自闭症患者 2020-12-02 08:52

Is there a way to generate MD5 Hash string of type varchar(32) without using fn_varbintohexstr

SUBSTRING(master.dbo.fn_varbintohexstr(HashBytes(\'MD5\', \'em         


        
9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 09:32

    For data up to 8000 characters use:

    CONVERT(VARCHAR(32), HashBytes('MD5', 'email@dot.com'), 2)
    

    Demo

    For binary data (without the limit of 8000 bytes) use:

    CONVERT(VARCHAR(32), master.sys.fn_repl_hash_binary(@binary_data), 2)
    

    Demo

提交回复
热议问题