<commit_before><!doctype html><title>Random passphrase</title>
<p>Passphrase: “<output id=passphraseOutput></output>”.
<p>Entropy: <output id=entropyOutput></output>.
<script src=./browser.js></script>
<script>
  passphrase({entropy: 64, insertions: 1}, function(e, s, entr) {
    if (e !== null) {
      console.error('Error generating password:', e);
      alert('Error generating password. Maybe try with another browser.');
    }
    passphraseOutput.textContent = s;
    entropyOutput.textContent = entr;
  });
</script><commit_msg>Add parameter to webpage for security choices<commit_after><!doctype html><title>Random passphrase</title>
<p>Expected time left to live: <input type=number value=246 id=yearsInput> years.
<p>Yearly budget of adversaries:
  <input type=number value=10000000 id=costInput> thousand euros.
<p><button id=genBut>Generate password</button>
<p><strong>Generated passphrase:</strong>
  <code><output id=passphraseOutput>Awaiting generation</output></code>.
<p>Entropy: <output id=entropyOutput>Awaiting generation</output> bits.
<script src=./browser.js></script>
<script>
  // Lifetime in years of life left, budget in million euros.
  function genpw(params = {lifetime: 246, budget: 10000000}) {
    return new Promise(function(resolve, reject) {
      var entropy = (Math.log(params.budget/12) + Math.log(1000/0.03)
          + Math.log(params.lifetime) + Math.log(365*24*3600/0.005))
        / Math.log(2) + 1;
      passphrase({entropy: entropy}, function(e, s, entr) {
        if (e !== null) { reject(e); return; }
        resolve({passphrase: s, entropy: entr});
      });
    });
  }

  function computepw() {
    genpw({lifetime: +yearsInput.value, budget: +costInput.value})
    .then(function(state) {
      passphraseOutput.textContent = state.passphrase;
      entropyOutput.textContent = state.entropy.toFixed(2);
    }).catch(function(e) {
      console.error('Error generating password:', e);
      alert('Error generating password. Maybe try with another browser.');
    });
  }

  addEventListener('DOMContentLoaded', function() {
    computepw();
    genBut.addEventListener('click', computepw);
  });
</script>
{'fraction_non_alphanumeric': 0.15448658649398705, 'fraction_numerical': 0.02312673450508788, 'mean_word_length': 4.314496314496314, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6379713', 'n_tokens_mistral': 705, 'n_tokens_neox': 662, 'n_words': 155}