Class JKPasswordUtil

java.lang.Object
com.jk.core.security.JKPasswordUtil

public final class JKPasswordUtil extends Object
This class is an utility class used for handling and generating passwords.
Version:
1.0
Author:
Mohamed Kiswani
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    This method generates a password consisting of a mix of numeric, lower-case, and upper-case characters.
    static String
    generateNumricPassword(int numberOfChar)
    This method generates a numeric password consisting of digits.
    static String
    getAlphapticPassowrds(int numberOfChar, boolean islowerCase)
    This method generates an alphabetic password consisting of either lower-case or upper-case characters.
    static String
    hash(String value)
    This method hashes the provided value using the default password hashing mechanism.
    static void
    main(String[] args)
    This main method prints a generated mixed password.
    static boolean
    matches(String rawPassword, String encodedPassword)
    This method checks if a raw password matches an encoded password.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JKPasswordUtil

      public JKPasswordUtil()
  • Method Details

    • generateMixPassword

      public static String generateMixPassword(int n)
      This method generates a password consisting of a mix of numeric, lower-case, and upper-case characters.
      Parameters:
      n - Specifies the length of the generated password.
      Returns:
      the generated password.
    • generateNumricPassword

      public static String generateNumricPassword(int numberOfChar)
      This method generates a numeric password consisting of digits.
      Parameters:
      numberOfChar - Specifies the number of digits in the generated password.
      Returns:
      the generated numeric password.
    • getAlphapticPassowrds

      public static String getAlphapticPassowrds(int numberOfChar, boolean islowerCase)
      This method generates an alphabetic password consisting of either lower-case or upper-case characters.
      Parameters:
      numberOfChar - Specifies the number of characters in the generated password.
      islowerCase - Specifies whether the password should be in lower-case (true), or upper-case (false).
      Returns:
      the generated alphabetic password.
    • main

      public static void main(String[] args)
      This main method prints a generated mixed password.
      Parameters:
      args - the command line arguments.
    • hash

      public static String hash(String value)
      This method hashes the provided value using the default password hashing mechanism.
      Parameters:
      value - Specifies the value to be hashed.
      Returns:
      the hashed value.
    • matches

      public static boolean matches(String rawPassword, String encodedPassword)
      This method checks if a raw password matches an encoded password.
      Parameters:
      rawPassword - Specifies the plain text password to be checked.
      encodedPassword - Specifies the encoded password.
      Returns:
      true, if the passwords match, false otherwise.