Generate password on frontend instead

This commit is contained in:
Lncvrt committed 2026-02-18 00:33:33 -07:00
1 parent dff4b45adf
commit 3a1815aec3
3 files changed
+10 -18

No files matched your search

+9 -3
View File
@@ -1,5 +1,4 @@
import { useState, useEffect, useCallback } from 'react'
import { invoke } from '@tauri-apps/api/core'
import '@fontsource/lexend'
import './App.css'
@@ -10,8 +9,15 @@ function App () {
const presets = [6, 8, 12, 16, 24, 32, 50, 100, 200, 250]
const generatePassword = useCallback(async () => {
setPassword(await invoke('generate_password', { length }))
const generatePassword = useCallback(() => {
const chars =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*'
setPassword(
Array.from(
{ length },
() => chars[Math.floor(Math.random() * chars.length)]
).join('')
)
}, [length])
const copyToClipboard = () => {