JAVA   17

Verify

Guest on 14th August 2022 06:32:30 AM

  1. // The following code will authenticate the monitor
  2. // passwd is the user's password, chksum is the string returned by the monitor
  3. // when sending the "PARTICIPANT_PASSWORD_CHECKSUM" directive
  4. import java.security.*;
  5. import java.math.*;
  6.  
  7. class Verify {
  8.    public Verify (String passwd, String chksum) {
  9.       try {
  10.          MessageDigest md = MessageDigest.getInstance("SHA");
  11.          passwd = passwd.toUpperCase();
  12.          byte[] byteArr = passwd.getBytes();
  13.          md.update(byteArr);
  14.          byte[] out = md.digest();
  15.          BigInteger big1 = new BigInteger(out);
  16.          System.out.println(big1.abs().toString(16));
  17.          BigInteger big2 = new BigInteger(1, out);
  18.          System.out.println(big2.toString(16));
  19.       } catch (Exception e) {  }
  20.    }
  21. }
  22.  
  23. public class V {
  24.    public static void main (String a[]) {
  25.       Verify v = new Verify("Hello There", "Thanks");
  26.    }
  27. }

Raw Paste


Login or Register to edit or fork this paste. It's free.