You need to sign in to do that
Don't have an account?
Antoine LELEU 10
Java Hash Function to Apex
Hello,
I would like to use this hash function in Apex. Is it possible to Mapp this java function in apex function ?
public string Hash(string ToHash)
{
ToHash = ToHash.ToLower();
Encoder enc = System.Text.Encoding.ASCII.GetEncoder();
byte[] data = new byte[ToHash.Length];
enc.GetBytes(ToHash.ToCharArray(), 0, ToHash.Length, data, 0, true);
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] result = sha1.ComputeHash(data);
return BitConverter.ToString(result).Replace("-", "").ToLower();
}
Thanks for your help !
Antoine
I would like to use this hash function in Apex. Is it possible to Mapp this java function in apex function ?
public string Hash(string ToHash)
{
ToHash = ToHash.ToLower();
Encoder enc = System.Text.Encoding.ASCII.GetEncoder();
byte[] data = new byte[ToHash.Length];
enc.GetBytes(ToHash.ToCharArray(), 0, ToHash.Length, data, 0, true);
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] result = sha1.ComputeHash(data);
return BitConverter.ToString(result).Replace("-", "").ToLower();
}
Thanks for your help !
Antoine
You can use Crypto class and their function.
https://developer.salesforce.com/page/Apex_Crypto_Class
-Thanks
Ashlekh Gera
Thanks for your answer.
I already knew this Apex_Crypto_Class but i'm not able to transcode the function from C# to Apex.
Can you help me ?
Thanks,
Antoine