cdw1p icon

SHA512 Encription Function

cdw1p | PRO | 04/09/20 06:18:33 PM UTC | 0 ⭐ | 636 👁️ | Never ⏰ | []
C# |

750 B

|

None

|

0 👍

/

0 👎

using System;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Data;
using System.Collections.Generic;
                    
public class Program
{
    public static void Main()
    {
        string xHasil;
        string xPassword = "String";
    
        SHA512Managed sham = new SHA512Managed();
        ASCIIEncoding ae = new ASCIIEncoding();
        byte[] Hash = sham.ComputeHash(ae.GetBytes(xPassword.Trim()));
        StringBuilder sb = new StringBuilder(Hash.Length * 2);
 
        for (int idx = 0; idx <= Hash.Length - 1; idx++) {
            string temp = "0" + string.Format("{0:x4}", Hash[idx]);
            sb.Append(temp.Substring(temp.Length - 2));
        }
 
        xHasil = sb.ToString().Trim().ToUpper();
        return xHasil;
    }
}

Comments