Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function reboot() {
- var msg = document.querySelector('#pwd1').value;
- alert(msg);
- digestMsg(msg).then(result=>{
- var opt = document.querySelector('[name="opt"]');
- var chk = document.querySelector('[name="chk1"]');
- opt.value = 3;
- chk.value = digToHex(result);
- // document.querySelector('form').submit();
- console.log(opt.value);
- console.log(chk.value);
- });
- // form.submit();
- }
- function digToHex(buf) {
- const bytes = new Uint8Array(buf);
- const hexCodes = [...bytes].map(value => {
- const hexCode = value.toString(16);
- const padHexCode = hexCode.padStart(2, '0');
- return padHexCode;
- });
- return hexCodes.join('');
- }
- function digestMsg(msg) {
- const enc = new TextEncoder();
- const data = enc.encode(msg);
- return window.crypto.subtle.digest('SHA-1', data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement