Package Components

Class Encrypter


  • public final class Encrypter
    extends java.lang.Object
    Encrypter class for encrypting password using hash and salt
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Encrypter()
      Private constructor to hinder creation of utility class
    • Method Summary

      Modifier and Type Method Description
      private static byte[] buildBytes​(java.lang.String hex)
      Hex-to-byte converter
      private static java.lang.String buildHexString​(byte[] bytes)
      Byte-to-Hex converter
      static java.lang.String encrypt​(java.lang.String password, java.lang.String saltest)
      Encryption used for the password, method is used for both making and verifying an encrypted password.
      static java.lang.String getHash​(java.lang.String s)
      Used to get the hash string from the encrypt function
      static java.lang.String getSalt​(java.lang.String s)
      Used to get the salt string from the encrypt function
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Encrypter

        private Encrypter()
        Private constructor to hinder creation of utility class
    • Method Detail

      • encrypt

        public static java.lang.String encrypt​(java.lang.String password,
                                               java.lang.String saltest)
        Encryption used for the password, method is used for both making and verifying an encrypted password.
        Parameters:
        password - String password that the user har entered
        saltest - String hex values for the salt
        Returns:
        String combination of both "hash|salt", uses splitters to get either
      • buildHexString

        private static java.lang.String buildHexString​(byte[] bytes)
        Byte-to-Hex converter
        Parameters:
        bytes - is an array of byte
        Returns:
        String bytes in hex
      • buildBytes

        private static byte[] buildBytes​(java.lang.String hex)
        Hex-to-byte converter
        Parameters:
        hex - input to get an byte array
        Returns:
        byte[] converted from hex
      • getHash

        public static java.lang.String getHash​(java.lang.String s)
        Used to get the hash string from the encrypt function
        Parameters:
        s - the output from encrypt
        Returns:
        String hash
      • getSalt

        public static java.lang.String getSalt​(java.lang.String s)
        Used to get the salt string from the encrypt function
        Parameters:
        s - the output from encrypt
        Returns:
        String salt