<commit_before>genkeypair() {
  usage $# "KEY_PRIVATE_FILE" "[KEY_SIZE:4096|521]" "[KEY_TYPE:rsa|ecdsa]"
  ## Display Usage and exit if insufficient parameters. Parameters prefix with [ are OPTIONAL.
  if [[ "$?" -ne 0 ]]; then return -1; fi

  local KEY_PRIVATE_FILE=$1
  local KEY_SIZE=${2:-4096}
  local KEY_TYPE=${3:-rsa}

  #if [[ ! $KEY_PRIVATE_FILE == *\.* ]]; then
    local KEY_PRIVATE_FILE="${KEY_PRIVATE_FILE}-${KEY_TYPE}-${KEY_SIZE}"
  #fi

  echo "ssh-keygen -t ${KEY_TYPE} -b ${KEY_SIZE} -f ${KEY_PRIVATE_FILE}"
  ssh-keygen -t ${KEY_TYPE} -b ${KEY_SIZE} -f ${KEY_PRIVATE_FILE}

  ll ${KEY_PRIVATE_FILE}
}
# https://www.golinuxcloud.com/generate-self-signed-certificate-openssl/
gencertkey() {
  usage $# "CERT_FILE:server|server.crt" "[KEY_PRIVATE_FILE:server.key]" "[KEY_SIZE:4096|521]" "[KEY_TYPE:rsa|ecdsa]" "[TTL:365]" "[EXTRA_PARAMS]"
  ## Display Usage and exit if insufficient parameters. Parameters prefix with [ are OPTIONAL.
  if [[ "$?" -ne 0 ]]; then return 1; fi

  local CERT_FILE=$1
  local KEY_PRIVATE_FILE=$2
  local KEY_SIZE=${3:-4096}
  local KEY_TYPE=${4:-rsa}
  local TTL=${5:-365}
  local EXTRA_PARAMS=${@:6}

  if [[ -n "${KEY_PRIVATE_FILE}" ]]
    then
      local KEY_PRIVATE_FILE_PATH=${KEY_PRIVATE_FILE}
    else
      local KEY_PRIVATE_FILE_PATH="${CERT_FILE}.key"
  fi

  gencertself "${CERT_FILE}" "gen" "${TTL}" "-newkey ${KEY_TYPE}:${KEY_SIZE} -keyout ${KEY_PRIVATE_FILE_PATH} ${EXTRA_PARAMS}"
}
gencertself() {
  usage $# "CERT_FILE:server|server.crt" "KEY_PRIVATE_FILE_PATH:gen" "[TTL:365]" "[EXTRA_PARAMS]"<commit_msg>Change key generation pattern to allow ssh-agent import => for i in $1/*rsa; do sshagentaddfiles "$i"; done<commit_after>genkeypair() {
  usage $# "KEY_PRIVATE_FILE" "[KEY_SIZE:4096|521]" "[KEY_TYPE:rsa|ecdsa]"
  ## Display Usage and exit if insufficient parameters. Parameters prefix with [ are OPTIONAL.
  if [[ "$?" -ne 0 ]]; then return -1; fi

  local KEY_PRIVATE_FILE=$1
  local KEY_SIZE=${2:-4096}
  local KEY_TYPE=${3:-rsa}

  #if [[ ! $KEY_PRIVATE_FILE == *\.* ]]; then
    local KEY_PRIVATE_FILE="${KEY_PRIVATE_FILE}-${KEY_SIZE}-${KEY_TYPE}"
  #fi

  echo "ssh-keygen -t ${KEY_TYPE} -b ${KEY_SIZE} -f ${KEY_PRIVATE_FILE}"
  ssh-keygen -t ${KEY_TYPE} -b ${KEY_SIZE} -f ${KEY_PRIVATE_FILE}

  ll ${KEY_PRIVATE_FILE}
}
# https://www.golinuxcloud.com/generate-self-signed-certificate-openssl/
gencertkey() {
  usage $# "CERT_FILE:server|server.crt" "[KEY_PRIVATE_FILE:server.key]" "[KEY_SIZE:4096|521]" "[KEY_TYPE:rsa|ecdsa]" "[TTL:365]" "[EXTRA_PARAMS]"
  ## Display Usage and exit if insufficient parameters. Parameters prefix with [ are OPTIONAL.
  if [[ "$?" -ne 0 ]]; then return 1; fi

  local CERT_FILE=$1
  local KEY_PRIVATE_FILE=$2
  local KEY_SIZE=${3:-4096}
  local KEY_TYPE=${4:-rsa}
  local TTL=${5:-365}
  local EXTRA_PARAMS=${@:6}

  if [[ -n "${KEY_PRIVATE_FILE}" ]]
    then
      local KEY_PRIVATE_FILE_PATH=${KEY_PRIVATE_FILE}
    else
      local KEY_PRIVATE_FILE_PATH="${CERT_FILE}.key"
  fi

  gencertself "${CERT_FILE}" "gen" "${TTL}" "-newkey ${KEY_TYPE}:${KEY_SIZE} -keyout ${KEY_PRIVATE_FILE_PATH} ${EXTRA_PARAMS}"
}
gencertself() {
  usage $# "CERT_FILE:server|server.crt" "KEY_PRIVATE_FILE_PATH:gen" "[TTL:365]" "[EXTRA_PARAMS]"
{'fraction_non_alphanumeric': 0.17678018575851392, 'fraction_numerical': 0.027554179566563468, 'mean_word_length': 4.9284403669724774, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '730666', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1244, 'n_words': 250}