<commit_before>const openpgp = require('openpgp')
openpgp.initWorker({ path: '../node_modules/openpgp/dist/openpgp.worker.min.js' })
openpgp.config.aead_protect = true
openpgp.config.use_native = true

import keytar from 'keytar'

export function getPublicKeysFromKeychain(keychain) {
  return keychain.map(key => key.publicKeyArmored)
}

function applyFelonyBranding(openpgpBrandedKey) {
  let output
  output = openpgpBrandedKey.replace(/Version: OpenPGP\.js [^<]\d\.\d\.\d/g,
    'Version: 🔑 Felony (PGP made easy) v0.0.1')
  output = output.replace('Comment: http://openpgpjs.org', 'Comment: 👀 How dafuq do I use this? --> http://felony.io 😉')
  return output
}

function massagePGP(string) {
  return string.replace('\n', '\r\n')
               .replace('===', '==\r\n=')
}

function getNameString(key) {
  const userStr = key.users[0].userId.userid
  const email = userStr.substring(userStr.lastIndexOf('<') + 1, userStr.lastIndexOf('>'))
  const name = userStr.substring(0, userStr.lastIndexOf(' '))
  return `${ name } <${ email }>`
}

async function decryptPrivateKey(privateKey, passphrase) {
  const unlocked = await openpgp.decryptKey({
    privateKey,
    passphrase,
  })
  const decryptedKey = unlocked.key
  return decryptedKey
}

function getPrivateKeyPassphrase(privateKey) {
  const nameString = getNameString(privateKey)<commit_msg>Removing 'dafuq' from PGP Public Key comment<commit_after>const openpgp = require('openpgp')
openpgp.initWorker({ path: '../node_modules/openpgp/dist/openpgp.worker.min.js' })
openpgp.config.aead_protect = true
openpgp.config.use_native = true

import keytar from 'keytar'

export function getPublicKeysFromKeychain(keychain) {
  return keychain.map(key => key.publicKeyArmored)
}

function applyFelonyBranding(openpgpBrandedKey) {
  let output
  output = openpgpBrandedKey.replace(/Version: OpenPGP\.js [^<]\d\.\d\.\d/g,
    'Version: 🔑 Felony (PGP made easy) v0.0.1')
  output = output.replace('Comment: http://openpgpjs.org', 'Comment: 👀 How do I use this? --> http://felony.io 😉')
  return output
}

function massagePGP(string) {
  return string.replace('\n', '\r\n')
               .replace('===', '==\r\n=')
}

function getNameString(key) {
  const userStr = key.users[0].userId.userid
  const email = userStr.substring(userStr.lastIndexOf('<') + 1, userStr.lastIndexOf('>'))
  const name = userStr.substring(0, userStr.lastIndexOf(' '))
  return `${ name } <${ email }>`
}

async function decryptPrivateKey(privateKey, passphrase) {
  const unlocked = await openpgp.decryptKey({
    privateKey,
    passphrase,
  })
  const decryptedKey = unlocked.key
  return decryptedKey
}

function getPrivateKeyPassphrase(privateKey) {
  const nameString = getNameString(privateKey)
{'fraction_non_alphanumeric': 0.14803957493587394, 'fraction_numerical': 0.004397215097105167, 'mean_word_length': 4.504032258064516, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '6295264', 'n_tokens_mistral': 960, 'n_tokens_neox': 949, 'n_words': 192}