I'm trying to generate a hash value of a specific string in MD5 Base64. Is it possible to do it in a query within SQL Server?
I know there's a function to generate hashes in HashBytes(Algo,String)
, but there's no Base64 option.
Is there?
Thanks!
I'm trying to generate a hash value of a specific string in MD5 Base64. Is it possible to do it in a query within SQL Server?
I know there's a function to generate hashes in HashBytes(Algo,String)
, but there's no Base64 option.
Is there?
Thanks!
CREATE FUNCTION dbo.Base64Encode
(
@bin VARBINARY(MAX)
)
RETURNS VARCHAR(MAX)
AS
BEGIN
return CAST(N'' AS XML).value('xs:base64Binary(xs:hexBinary(sql:variable("@bin")))', 'VARCHAR(MAX)')
END
SELECT dbo.Base64Encode(HashBytes('MD5', ItemName))
FROM tblItems