Q:

What is the escape sequence for a space OR assist with my hash function?

I've looked everywhere and I can't seem to find the escape sequence for a space. I'm currently using " " for space but it's not working. I need it for my hash function which fails to compute properly when it hashes a password that includes a space character. 
For example when I input "aaa aaa" into my program, it outputs ">&q". My function should output a seven character hash based on the password, but it stops at the space instead, leaving only a three character output. However, the function can still output a space given certain inputs. 
import java.util.*;

public class Hasher {

    private static Scanner scan;

    /*
     * This function will generate a hash based off a password entered by the
     * user
     */
    public static void main(String[] args) {

        scan = new Scanner(System.in);

        System.out.println("What is your password?");

        String password = scan.next();

        String characters = "qwertyuiopasdfghjklzxcvbnm";
        characters = characters + characters.toUpperCase();
        characters = characters + "1234567890";
        characters = characters + " ";
        characters = characters + "!@#$%^&*()_+-=`~\b[]?-{};',./:\"<>?\\";

        char[] array = new char[2 * characters.length()];

        for (int y = 0; y < array.length; y++) {

            Random rand = new Random(y);
            array[y] = characters.charAt(rand.nextInt(characters.length()));
        }

        String newPass = "";

        for (int y = 0; y < password.length(); y++) {

            char x = password.charAt(y);

            for (int z = 0; z < characters.length(); z++) {

                if (x == characters.charAt(z)) {

                    Random rand = new Random(y);
                    x = array[z + rand.nextInt(array.length - z)];
                    newPass = newPass + x;
                    break;
                }
            }
        }

        System.out.println("Your hash is: " + newPass);

    }

}

A:

When you construct your Scanner object, pass in the delimiter as "\\n" so that it scans the entire line.
Something like:  new Scanner(System.in).useDelimiter("\\n");

A:

Just change
String password = scan.next();

to
String password = scan.nextLine();

