diff --git a/bun.lockb b/bun.lockb index 76ed761..aadea39 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/inputs/checkbox.vue b/components/inputs/checkbox.vue new file mode 100644 index 0000000..97a8240 --- /dev/null +++ b/components/inputs/checkbox.vue @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/components/inputs/password.vue b/components/inputs/password.vue index 1b16377..678b818 100644 --- a/components/inputs/password.vue +++ b/components/inputs/password.vue @@ -1,6 +1,16 @@ \ No newline at end of file + + + \ No newline at end of file diff --git a/utils/passwords.ts b/utils/passwords.ts new file mode 100644 index 0000000..8b86380 --- /dev/null +++ b/utils/passwords.ts @@ -0,0 +1,22 @@ +/** + * Get the strength of a password + * @param password The password to check + * @returns Number from 0 to Infinity representing the strength of the password + */ +export const passwordStrength = (password: string): number => { + const length = password.length; + const specialChars = password.match(/[^A-Za-z0-9]/g)?.length || 0; + const numbers = password.match(/[0-9]/g)?.length || 0; + const upperCase = password.match(/[A-Z]/g)?.length || 0; + const lowerCase = password.match(/[a-z]/g)?.length || 0; + + // Calculate the strength of the password + return ( + (length * 4 + + specialChars * 6 + + numbers * 4 + + upperCase * 2 + + lowerCase * 2) / + 16 + ); +};