Generate password on frontend instead
This commit is contained in:
3 files changed
+10
-18
No files matched your search
+9
-3
@@ -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 = () => {
|
||||
|
||||
Reference in new issue
Block a user