"use client"; import { useEffect, useState } from "react"; import { useDropzone } from "react-dropzone"; import { Icon } from "@iconify/react"; import TagSelector from "./submit/tag-selector"; import QrUpload from "./submit/qr-upload"; import QrScanner from "./submit/qr-scanner"; import { AES_CCM } from "@trafficlunar/asmcrypto.js"; const key = new Uint8Array([0x59, 0xfc, 0x81, 0x7e, 0x64, 0x46, 0xea, 0x61, 0x90, 0x34, 0x7b, 0x20, 0xe9, 0xbd, 0xce, 0x52]); export default function SubmitForm() { const { acceptedFiles, getRootProps, getInputProps } = useDropzone({ accept: { "image/*": [".png", ".jpg", ".jpeg", ".bmp", ".webp"], }, }); const [isQrScannerOpen, setIsQrScannerOpen] = useState(false); const [qrBytes, setQrBytes] = useState(new Uint8Array()); useEffect(() => { if (qrBytes.length == 0) return; const decrypt = async () => { const nonce = qrBytes.subarray(0, 8); const content = qrBytes.subarray(8, 0x70); const nonceWithZeros = new Uint8Array(12); nonceWithZeros.set(nonce, 0); const decrypted = AES_CCM.decrypt(content, key, nonceWithZeros, undefined, 16); const result = new Uint8Array([...decrypted.subarray(0, 12), ...qrBytes.subarray(0, 8), ...decrypted.subarray(12, decrypted.length - 4)]); console.log(result); }; decrypt(); }, [qrBytes]); return (
e.preventDefault()} className="grid grid-cols-2">

Drag and drop your images here
or click to open

{/* todo: show file list here */}
QR Code or
); }