Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple ISO verification hashing done on the client #3189

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions download.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
require_once __DIR__.'/_backend/preload.php';

$page['name'] = 'Verify Download';
$page['title'] = 'Verify your OS Download';

include $template['header'];
?>

<div style='margin: 16rem 8rem;'>
<h2>Verify Your OS Download<h2>

<input type=file />
<span id=hash></span>
</div>

<script type='module'>
console.log('ok lets get down to business')
const input = document.querySelector('input[type=file]')

input.addEventListener('change', getFile)

async function getFile() {
const file = this.files[0];

console.log('got file!')
console.log(file)
window.file = file;
const Reader = new FileReader(file)
const buf = await file.arrayBuffer();
// const buf = Reader.readAsArrayBuffer(file)

console.log(buf)

const hash = await crypto.subtle.digest('SHA-256', buf)

const uintHash = new Uint8Array(hash);

// Map the new intHash to Hex to be displayed as a string value
const stringifiedHash = Array.from(uintHash).map((b) => b.toString(16).padStart(2, '0')).join('');

document.querySelector('#hash').innerText = stringifiedHash;

}
</script>

<?php
include $template['footer'];
?>