From 05bb65fc037dbd21ec054b52d27ddf894fb66201 Mon Sep 17 00:00:00 2001 From: Roland Date: Wed, 1 Jul 2026 18:48:06 -0600 Subject: [PATCH] Moving OTP and Vin decoder to calculators to save Navbar space. Reworking calculators to purpose groups, and adding colors. --- app/src/components/Apps.js | 292 +----------------- app/src/components/Calculators.js | 61 +++- app/src/components/Nav.js | 4 +- app/src/components/Search.js | 8 +- .../calculators/OneTimePadCalculator.js | 221 +++++++++++++ .../calculators/OneTimePadCalculator.test.js | 28 ++ .../calculators/VinDecoderCalculator.js | 53 ++++ .../calculators/VinDecoderCalculator.test.js | 14 + 8 files changed, 373 insertions(+), 308 deletions(-) create mode 100644 app/src/components/calculators/OneTimePadCalculator.js create mode 100644 app/src/components/calculators/OneTimePadCalculator.test.js create mode 100644 app/src/components/calculators/VinDecoderCalculator.js create mode 100644 app/src/components/calculators/VinDecoderCalculator.test.js diff --git a/app/src/components/Apps.js b/app/src/components/Apps.js index 877cc183..5085c65b 100644 --- a/app/src/components/Apps.js +++ b/app/src/components/Apps.js @@ -1,302 +1,20 @@ -import React, {useContext, useState} from 'react'; -import { - Checkbox, - Divider, - Icon, - Input, - Label, - Radio, - SegmentGroup, - StatisticLabel, - StatisticValue, - TableCell, - TableRow -} from "semantic-ui-react"; +import React, {useContext} from 'react'; +import {Input, Label, StatisticLabel, StatisticValue} from "semantic-ui-react"; import {Link, Route, Routes} from "react-router"; -import { - appendChecksum, - decryptOTP, - encryptOTP, - formatMessage, - generateHtml, - OTP_CHARS, - OTP_CHARS_ALPHA, - stripChecksum, - validateCharset -} from "./otp"; import { ErrorMessage, humanFileSize, humanNumber, mimetypeColor, PageContainer, - SimpleAccordion, toLocaleString, useTitle } from "./Common"; import {ThemeContext} from "../contexts/contexts"; -import {Button, Form, Header, Loader, Segment, Statistic, Table, TextArea} from "./Theme"; -import {useStatistics, useVINDecoder} from "../hooks/customHooks"; +import {Header, Loader, Segment, Statistic} from "./Theme"; +import {useStatistics} from "../hooks/customHooks"; import {CalculatorsPage} from "./Calculators"; -function Encrypt({chars, checksum}) { - // Encrypt happens live as the user types or pastes. Nothing leaves the browser. - const [otp, setOtp] = useState(''); - const [plaintext, setPlaintext] = useState(''); - - const handleInputChange = (event, {name, value}) => { - if (name === 'otp') { - setOtp(value); - } else { - setPlaintext(value); - } - }; - - let ciphertext = ''; - let error = ''; - if (otp && plaintext && chars) { - try { - const raw = encryptOTP(otp, plaintext, chars).ciphertext; - // When enabled, append a checksum character then re-group the whole message+checksum. - ciphertext = checksum ? formatMessage(appendChecksum(raw, chars)) : raw; - } catch (e) { - error = e.message; - } - } - - return <> -
Encrypt
- - -

Key

-