import { a as __unplugin_components_1 } from './chunk-8109fd17.js'; import { _ as __unplugin_components_3 } from './chunk-4e7a6a8d.js'; import { defineComponent, ref, computed, mergeProps, unref, isRef, withCtx, createVNode, toDisplayString, openBlock, createBlock, Fragment, renderList, useSSRContext } from 'vue'; import { ssrRenderAttrs, ssrRenderComponent, ssrInterpolate, ssrRenderList } from 'vue/server-renderer'; import _ from 'lodash'; import './chunk-6003391e.js'; import '@vueuse/core'; import 'pinia'; import './chunk-11f44f81.js'; import './chunk-35c3d701.js'; function prettifyExponentialNotation(exponentialNotation) { const [base, exponent] = exponentialNotation.toString().split("e"); const baseAsNumber = Number.parseFloat(base); const prettyBase = baseAsNumber % 1 === 0 ? baseAsNumber.toLocaleString() : baseAsNumber.toFixed(2); return exponent ? `${prettyBase}e${exponent}` : prettyBase; } function getHumanFriendlyDuration({ seconds }) { if (seconds <= 1e-3) { return "Instantly"; } if (seconds <= 1) { return "Less than a second"; } const timeUnits = [ { unit: "millenium", secondsInUnit: 31536e6, format: prettifyExponentialNotation, plural: "millennia" }, { unit: "century", secondsInUnit: 31536e5, plural: "centuries" }, { unit: "decade", secondsInUnit: 31536e4, plural: "decades" }, { unit: "year", secondsInUnit: 31536e3, plural: "years" }, { unit: "month", secondsInUnit: 2592e3, plural: "months" }, { unit: "week", secondsInUnit: 604800, plural: "weeks" }, { unit: "day", secondsInUnit: 86400, plural: "days" }, { unit: "hour", secondsInUnit: 3600, plural: "hours" }, { unit: "minute", secondsInUnit: 60, plural: "minutes" }, { unit: "second", secondsInUnit: 1, plural: "seconds" } ]; return _.chain(timeUnits).map(({ unit, secondsInUnit, plural, format = _.identity }) => { const quantity = Math.floor(seconds / secondsInUnit); seconds %= secondsInUnit; if (quantity <= 0) { return void 0; } const formattedQuantity = format(quantity); return `${formattedQuantity} ${quantity > 1 ? plural : unit}`; }).compact().take(2).join(", ").value(); } function getPasswordCrackTimeEstimation({ password, guessesPerSecond = 1e9 }) { const charsetLength = getCharsetLength({ password }); const passwordLength = password.length; const entropy = password === "" ? 0 : Math.log2(charsetLength) * passwordLength; const secondsToCrack = 2 ** entropy / guessesPerSecond; const crackDurationFormatted = getHumanFriendlyDuration({ seconds: secondsToCrack }); const score = Math.min(entropy / 128, 1); return { entropy, charsetLength, passwordLength, crackDurationFormatted, secondsToCrack, score }; } function getCharsetLength({ password }) { const hasLowercase = /[a-z]/.test(password); const hasUppercase = /[A-Z]/.test(password); const hasDigits = /\d/.test(password); const hasSpecialChars = /\W|_/.test(password); let charsetLength = 0; if (hasLowercase) { charsetLength += 26; } if (hasUppercase) { charsetLength += 26; } if (hasDigits) { charsetLength += 10; } if (hasSpecialChars) { charsetLength += 32; } return charsetLength; } const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "password-strength-analyser", __ssrInlineRender: true, setup(__props) { const password = ref(""); const crackTimeEstimation = computed(() => getPasswordCrackTimeEstimation({ password: password.value })); const details = computed(() => [ { label: "Password length:", value: crackTimeEstimation.value.passwordLength }, { label: "Entropy:", value: Math.round(crackTimeEstimation.value.entropy * 100) / 100 }, { label: "Character set size:", value: crackTimeEstimation.value.charsetLength }, { label: "Score:", value: `${Math.round(crackTimeEstimation.value.score * 100)} / 100` } ]); return (_ctx, _push, _parent, _attrs) => { const _component_c_input_text = __unplugin_components_3; const _component_c_card = __unplugin_components_1; _push(`