- // The following code will authenticate the monitor
- // passwd is the user's password, chksum is the string returned by the monitor
- // when sending the "PARTICIPANT_PASSWORD_CHECKSUM" directive
- public boolean Verify(String passwd, String chksum) {
- try {
- MessageDigest md = MessageDigest.getInstance("SHA");
- passwd = passwd.toUpperCase();
- byte[] byteArr = passwd.getBytes();
- md.update(byteArr);
- // *** The following two lines are deprecated - use Coleman Kane's ***
- // *** modification following them ***
- // BigInteger big = new BigInteger(md.digest());
- // if ((big.abs().toString(16).equals(chksum.trim()))) return true;
- BigInteger big = new BigInteger(1, md.digest());
- if ((big.toString(16).equals(chksum.trim()))) return true;
- else return false;
- } catch (Exception e) {
- return false;
- }
- }
Raw Paste