package fii.admission.hash;

import java.security.MessageDigest;

/**
 * Created by andy on 20.05.2017.
 */
public class HashConvertor {
    private String str;
    private String hashType;

    public HashConvertor(String str) {
        this(str, "SHA-256");
    }

    public HashConvertor(String str , String hashType){
        this.str=str;
        this.hashType=hashType;
    }
    public String toString() {
        try {
            MessageDigest digest = MessageDigest.getInstance(this.hashType);
            byte[] hash = digest.digest(this.str.getBytes("UTF-8"));
            StringBuffer hexString = new StringBuffer();
            int lg = hash.length;
            for (int i = 0; i < lg; i++) {
                String hex = Integer.toHexString(0xff & hash[i]);
                if (hex.length() == 1) {
                    hexString.append('0');
                }
                hexString.append(hex);
            }

            return hexString.toString();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
}

@@ -38,30 +38,119 @@
 ava.
-security.MessageDigest
+math.BigInteger;%0Aimport java.security.MessageDigest;%0Aimport java.security.SecureRandom;%0Aimport java.util.Random
 ;%0A%0A/
@@ -510,16 +510,58 @@
   try %7B%0A
+            //Random rand = new Random();%0A
         
@@ -629,16 +629,183 @@
 hType);%0A
+            SecureRandom random = new SecureRandom();%0A            String salt = new BigInteger(0x32, random).toString(0x20);%0A            String str = this.str + salt;%0A
         
@@ -836,21 +836,16 @@
 .digest(
-this.
 str.getB
@@ -1235,16 +1235,17 @@
  return 
+(
 hexStrin
@@ -1256,16 +1256,24 @@
 String()
+ + salt)
 ;%0A      

Update HashConvertor.java