Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. public class Part4 {
  2.     public static String hash(String input,String algorithm)throws NoSuchAlgorithmException {
  3.         char[] inputArray = input.toCharArray();
  4.         StringBuilder resultString = new StringBuilder();
  5.         for (int i = 0; i<inputArray.length; i++) {
  6.             resultString.append(String.format("%02X ", (byte)inputArray[i]));
  7.         }
  8.         return resultString.toString();
  9.     }
  10.  
  11.     public static void main(String[]args)throws NoSuchAlgorithmException{
  12.         System.out.println(hash("password","SHA-256"));
  13.         System.out.println(hash("passwort","SHA-256"));
  14.     }
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement