U8的登陆密码

https://blog.csdn.net/mxbing1984/article/details/93004373

public partial class UserDefinedFunctions
{
    [Microsoft.SqlServer.Server.SqlFunction]
    public static SqlString U8password(string pwd)
    {
        byte[] MessageBytes = UnicodeEncoding.UTF8.GetBytes(pwd);
        SHA1Managed SHhash = new SHA1Managed();
 
        byte[] HashValue = SHhash.ComputeHash(MessageBytes);
 
        return new SqlString(Convert.ToBase64String(HashValue) +(char)3);
 
    }
 
}

--SQL版
CREATE FUNCTION [dbo].[FnBase64Encode](@src varchar(MAX))
RETURNS VARCHAR(MAX)
AS
BEGIN
	DECLARE @bin VARBINARY(MAX)
	SET @bin=CONVERT(VARBINARY(MAX), @src)
	RETURN CAST(N'' AS XML).value('xs:base64Binary(xs:hexBinary(sql:variable("@bin")))', 'varchar(max)')
END
Go
 
 
SELECT dbo.FnBase64Encode( HASHBYTES('SHA1','123456'))+CHAR(3)
SELECT cPassword FROM dbo.UA_User WHERE cUser_Name='test'

posted @ 2026-08-30 19:15  清哥的码农生活  阅读(2)  评论(0)    收藏  举报