<commit_before><template>
    {{ field.display || field.name }}
    <button @click="editing = !editing"></button>
    <div v-if="editing">
        <label>
            <input
                type="password"
                :name="field.name"
                :minLength="field.minLength"
                :maxLength="field.maxLength"
                :value="value"
            />
        </label>
        <button @click="$emit('value-change', sha256(value))"></button>
    </div>
</template>

<script>
  import crypto from 'crypto'

  function sha256 (password) {
    return crypto.createHash('sha256')
      .update(password)
      .digest('base64')
  }
  
  export default {
    name: 'password-field',
    props: ['field'],
    editing: false,
    value: '',
    sha256
  }
</script>

<style scoped>

</style><commit_msg>Using salt<commit_after><template>
    {{ field.display || field.name }}
    <button @click="editing = !editing"></button>
    <div v-if="editing">
        <label>
            <input
                type="password"
                :name="field.name"
                :minLength="field.minLength"
                :maxLength="field.maxLength"
                :value="value"
            />
        </label>
        <button @click="$emit('value-change', hashedJson(value))"></button>
    </div>
</template>

<script>
  import crypto from 'crypto'
  
  const SALT_LENGTH = 6

  function hashedJson (password) {
    let salt = crypto.randomBytes(Math.ceil(SALT_LENGTH/2))
            .toString('base64')
            .slice(0, SALT_LENGTH)
    let hashedPassword = crypto.createHash('sha256')
      .update(password + salt)
      .digest('base64')
    return { hash: hashedPassword, salt }
  }
  
  export default {
    name: 'password-field',
    props: ['field'],
    editing: false,
    value: '',
    hashedJson
  }
</script>

<style scoped>

</style>
{'fraction_non_alphanumeric': 0.15417558886509636, 'fraction_numerical': 0.01284796573875803, 'mean_word_length': 2.0689655172413794, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '3102612', 'n_tokens_mistral': 599, 'n_tokens_neox': 569, 'n_words': 109}