MessageDigest digest = MessageDigest.getInstance("SHA-256");
        byte[] hash = digest.digest(base.getBytes("UTF-8"));
        StringBuffer hexString = new StringBuffer();
        for (int i = 0; i < hash.length; i++) {
            String hex = Integer.toHexString(0xff & hash[i]);
            if(hex.length() == 1) hexString.append('0');
            hexString.append(hex);
        }
i wanted to convert "hexString" to string that contains only "a-zA-z0-9[!@#$%&*()_+=&|<>?{}[]~""]-" characters.
output may repeat in some cases but it should produce same string every time for same hexString