Skip to content

Commit

Permalink
fix errors in encryption page
Browse files Browse the repository at this point in the history
  • Loading branch information
emiljohansson committed Feb 25, 2023
1 parent e5565d1 commit 48d5338
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions apps/next/app/encryption/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ import Content from '@/components/Content'
import Section from '@/components/Section'

const Encrypt = () => {
const secretRef = useRef(null)
const stringRef = useRef(null)
const secretRef = useRef<HTMLInputElement>(null)
const stringRef = useRef<HTMLInputElement>(null)
const [encryptedValue, setEncryptedValue] = useState('')

function onChange() {
const secret = secretRef.current.value
const string = stringRef.current.value
const secret = secretRef.current?.value
const string = stringRef.current?.value
console.log({
secret,
string
});

if (!secret || !string) return
const encrypted = AES.encrypt(string, secret).toString()
setEncryptedValue(encrypted)
}
Expand All @@ -42,13 +48,19 @@ const Encrypt = () => {
}

const Decrypt = () => {
const secretRef = useRef(null)
const stringRef = useRef(null)
const secretRef = useRef<HTMLInputElement>(null)
const stringRef = useRef<HTMLInputElement>(null)
const [decryptedValue, setDecryptedValue] = useState('')

function onChange() {
const secret = secretRef.current.value
const encryptedValue = stringRef.current.value
const secret = secretRef.current?.value
const encryptedValue = stringRef.current?.value
console.log({
secret,
encryptedValue
});

if (!secret || !encryptedValue) return
const bytes = AES.decrypt(encryptedValue, secret)
setDecryptedValue(bytes.toString(enc.Utf8))
}
Expand Down

0 comments on commit 48d5338

Please sign in to comment.