package login;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class PasswordHelper
{
	public static String generatePasswordHash(String password)
	{
		//Create instances of digest and password char array
		MessageDigest passDigest;
		byte[] passArray;

		try
		{
			//Create instance of MessageDigest we can use to  
			passDigest = MessageDigest.getInstance("MD5");

			//Convert password to byte array 
			passArray = password.getBytes("UTF-8");
		}
		catch (NoSuchAlgorithmException e)
		{
			//Hardcoded algorithm type, this exception shouldn't be called
			e.printStackTrace();
			return "";
		}
		catch (UnsupportedEncodingException e)
		{
			//Hardcoded encoding type, this exception shouldn't be called
			e.printStackTrace();
			return "";
		}

		//Use digest to get an array of chars as a hash and return it as a string
		byte[] hashArray = passDigest.digest(passArray);
		return new String(hashArray);
	}

}

@@ -168,16 +168,120 @@
 elper%0A%7B%0A
+%09private static String hashAlgorithm = %22MD5%22;%0A%09private static String stringEncodingFormat = %22UTF-8%22; %0A%09%0A
 %09public 
@@ -545,21 +545,29 @@
 nstance(
-%22MD5%22
+hashAlgorithm
 );%0A%0A%09%09%09/
@@ -632,23 +632,36 @@
 etBytes(
-%22UTF-8%22
+stringEncodingFormat
 );%0A%09%09%7D%0A%09
@@ -704,74 +704,8 @@
 %09%09%7B%0A
-%09%09%09//Hardcoded algorithm type, this exception shouldn't be called%0A
 %09%09%09e
@@ -791,73 +791,8 @@
 %09%09%7B%0A
-%09%09%09//Hardcoded encoding type, this exception shouldn't be called%0A
 %09%09%09e

Move algorithm types to static strings on top