I have the following C# code:
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
public class Program
{
public static void Main()
{
string profileId = "TEST";
using (MD5 md5 = MD5.Create())
{
string playerGroup;
byte[] inputBytes = Encoding.UTF8.GetBytes(profileId);
byte[] hashBytes = md5.ComputeHash(inputBytes);
long hashCode = BitConverter.ToInt64(hashBytes, 0);
Console.WriteLine(hashCode);
}
}
}
The result: -1956981089572930813
I want to replicate the same process in SQL (Amazone Redshift).
But I get a different result.
If I do:
select from_hex(substring(md5('TEST'), 1, 16))::bigint
The result: 233018722177570788
Is there any way to reproduce the C# process on SQL (Redshift)?
I tried:
select from_hex(substring(md5('TEST'), 1, 16))::bigint
I was expecting: -1956981089572930813
I get: 233018722177570788
You need to sign in to view this answers
Leave feedback about this