SHARE
TWEET

Untitled

a guest Jun 25th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function reboot() {
  2.   var msg = document.querySelector('#pwd1').value;
  3. alert(msg);
  4.   digestMsg(msg).then(result=>{
  5.     var opt = document.querySelector('[name="opt"]');
  6.     var chk = document.querySelector('[name="chk1"]');
  7.     opt.value = 3;
  8.     chk.value = digToHex(result);
  9. //    document.querySelector('form').submit();
  10.  
  11. console.log(opt.value);
  12. console.log(chk.value);
  13.  
  14.   });
  15. //  form.submit();
  16. }
  17.  
  18. function digToHex(buf) {
  19.   const bytes = new Uint8Array(buf);
  20.   const hexCodes = [...bytes].map(value => {
  21.     const hexCode = value.toString(16);
  22.     const padHexCode = hexCode.padStart(2, '0');
  23.     return padHexCode;
  24.   });
  25.   return hexCodes.join('');
  26. }
  27.  
  28. function digestMsg(msg) {
  29.   const enc = new TextEncoder();
  30.   const data = enc.encode(msg);
  31.   return window.crypto.subtle.digest('SHA-1', data);
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top