public static String getPassword(final String prompt) {
        try {
            // password holder
            final StringBuffer password = new StringBuffer();
            final PasswordHidingThread maskingthread = new PasswordHidingThread(prompt);
            final Thread thread = new Thread(maskingthread);
            thread.start();

            // block until enter is pressed
            while (true) {
                char c = (char) System.in.read();

                // assume enter pressed, stop masking
                maskingthread.stopMasking();

                if (c == '\r') {
                    c = (char) System.in.read();

                    if (c == '\n') {
                        break;
                    } else {
                        continue;
                    }
                } else if (c == '\n') {
                    break;
                } else {
                    // store the password
                    password.append(c);
                }
            }

            return password.toString();
        } catch (final IOException e) {
            e.printStackTrace();
        }

        return null;
    }