Reputation: 32281
how can I convert the HASHBYTES return value to a GUID?
This is what I have so far.
CREATE PROCEDURE [dbo].[Login]
@email nvarchar,
@password varchar
AS
BEGIN
DECLARE @passHashBinary varbinary;
DECLARE @newPassHashBinary varbinary;
-- Create a unicode (utf-16) password
Declare @unicodePassword nvarchar;
Set @unicodePassword = CAST(@password as nvarchar);
SET @passHashBinary = HASHBYTES('md5', @password);
SET @newPassHashBinary = HASHBYTES('md5', @unicodePassword);
Upvotes: 3
Views: 7847
Reputation: 294227
Simply cast it:
select cast(hashbytes('md5','foo') as uniqueidentifier)
But there are two questions lingering:
BINARY(16)
Upvotes: 12