cdw1p

SHA512 Encription Function

Apr 9th, 2020
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Security.Cryptography;
  4. using System.Text;
  5. using System.Data;
  6. using System.Collections.Generic;
  7.                    
  8. public class Program
  9. {
  10.     public static void Main()
  11.     {
  12.         string xHasil;
  13.         string xPassword = "String";
  14.    
  15.         SHA512Managed sham = new SHA512Managed();
  16.         ASCIIEncoding ae = new ASCIIEncoding();
  17.         byte[] Hash = sham.ComputeHash(ae.GetBytes(xPassword.Trim()));
  18.         StringBuilder sb = new StringBuilder(Hash.Length * 2);
  19.  
  20.         for (int idx = 0; idx <= Hash.Length - 1; idx++) {
  21.             string temp = "0" + string.Format("{0:x4}", Hash[idx]);
  22.             sb.Append(temp.Substring(temp.Length - 2));
  23.         }
  24.  
  25.         xHasil = sb.ToString().Trim().ToUpper();
  26.         return xHasil;
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment