tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

util.js (472B)


      1 function base64urlEncode(data) {
      2  let result = btoa(data);
      3  return result.replace(/=+$/g, '').replace(/\+/g, "-").replace(/\//g, "_");
      4 }
      5 
      6 const sha256ofURL = async (url) => {
      7  const buffer = new TextEncoder().encode(url.toString());
      8  const hashBuffer = await window.crypto.subtle.digest('SHA-256', buffer);
      9  const hashArray = Array.from(new Uint8Array(hashBuffer));
     10  const arr = hashArray.map(b => String.fromCharCode(b)).join('');
     11  return base64urlEncode(arr);
     12 };