Skip to content

Commit 0835bf6

Browse files
committed
revert: undo RSA changes and API URL config
1 parent 3f02bc0 commit 0835bf6

File tree

3 files changed

+10
-63
lines changed

3 files changed

+10
-63
lines changed

next.config.mjs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const nextConfig = {
66
unoptimized: true,
77
},
88
env: {
9-
NEXT_PUBLIC_API_URL: 'https://bobbyal.pythonanywhere.com',
109
NEXT_PUBLIC_FIREBASE_API_KEY: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
1110
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
1211
NEXT_PUBLIC_FIREBASE_PROJECT_ID: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,

src/app/decrypt/page.jsx

+5-31
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,21 @@ export default function DecryptPage() {
1212
const [file, setFile] = useState(null);
1313
const [method, setMethod] = useState("aes");
1414
const [key, setKey] = useState("");
15-
const [privateKey, setPrivateKey] = useState("");
1615
const [decryptedFileUrl, setDecryptedFileUrl] = useState(null);
1716
const [decryptedFileName, setDecryptedFileName] = useState("");
1817
const [loading, setLoading] = useState(false);
1918

2019
const handleDecrypt = async () => {
21-
if (!file) {
22-
alert("Please select a file to decrypt.");
23-
return;
24-
}
25-
26-
if (method === "rsa" && !privateKey) {
27-
alert("Please enter a private key for RSA decryption.");
28-
return;
29-
}
30-
31-
if (method !== "rsa" && !key) {
32-
alert("Please enter a decryption key.");
20+
if (!file || (!key && method !== "rsa")) {
21+
alert("Please select a file and enter a key (except RSA).");
3322
return;
3423
}
3524

3625
setLoading(true);
3726
const formData = new FormData();
3827
formData.append("file", file);
3928
formData.append("method", method);
40-
formData.append("key", method === "rsa" ? privateKey : key);
29+
formData.append("key", key);
4130

4231
try {
4332
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/decrypt`, {
@@ -104,22 +93,7 @@ export default function DecryptPage() {
10493
<option value="rsa">RSA</option>
10594
</select>
10695

107-
{method === "rsa" ? (
108-
<>
109-
<label className="block text-sm font-semibold mb-2 text-gray-300">
110-
<div className="flex items-center">
111-
<FaKey className="w-4 h-4 mr-2" />
112-
Private Key
113-
</div>
114-
</label>
115-
<textarea
116-
placeholder="Paste RSA private key here"
117-
value={privateKey}
118-
onChange={(e) => setPrivateKey(e.target.value)}
119-
className="mb-6 w-full p-2 border border-gray-600 rounded-md bg-gray-900 text-sm text-white h-32 font-mono"
120-
/>
121-
</>
122-
) : (
96+
{method !== "rsa" && (
12397
<>
12498
<label className="block text-sm font-semibold mb-2 text-gray-300">
12599
<div className="flex items-center">
@@ -140,7 +114,7 @@ export default function DecryptPage() {
140114
<button
141115
onClick={handleDecrypt}
142116
disabled={loading}
143-
className="w-full bg-blue-600 hover:bg-blue-700 text-white py-3 rounded-lg font-semibold transition flex items-center justify-center disabled:opacity-50 disabled:cursor-not-allowed"
117+
className="w-full bg-blue-600 hover:bg-blue-700 text-white py-3 rounded-lg font-semibold transition flex items-center justify-center"
144118
>
145119
<FaLockOpen className="w-4 h-4 mr-2" />
146120
{loading ? "Decrypting..." : "Decrypt"}

src/app/encrypt/page.jsx

+5-31
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,21 @@ export default function EncryptPage() {
1212
const [file, setFile] = useState(null);
1313
const [method, setMethod] = useState("aes");
1414
const [key, setKey] = useState("");
15-
const [publicKey, setPublicKey] = useState("");
1615
const [encryptedFileUrl, setEncryptedFileUrl] = useState(null);
1716
const [encryptedFileName, setEncryptedFileName] = useState("");
1817
const [loading, setLoading] = useState(false);
1918

2019
const handleEncrypt = async () => {
21-
if (!file) {
22-
alert("Please select a file to encrypt.");
23-
return;
24-
}
25-
26-
if (method === "rsa" && !publicKey) {
27-
alert("Please enter a public key for RSA encryption.");
28-
return;
29-
}
30-
31-
if (method !== "rsa" && !key) {
32-
alert("Please enter an encryption key.");
20+
if (!file || (!key && method !== "rsa")) {
21+
alert("Please select a file and enter a key (except RSA).");
3322
return;
3423
}
3524

3625
setLoading(true);
3726
const formData = new FormData();
3827
formData.append("file", file);
3928
formData.append("method", method);
40-
formData.append("key", method === "rsa" ? publicKey : key);
29+
formData.append("key", key);
4130

4231
try {
4332
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/encrypt`, {
@@ -107,22 +96,7 @@ export default function EncryptPage() {
10796
</select>
10897

10998
{/* Key input */}
110-
{method === "rsa" ? (
111-
<>
112-
<label className="block text-sm font-semibold mb-2 text-gray-300">
113-
<div className="flex items-center">
114-
<FaKey className="w-4 h-4 mr-2" />
115-
Public Key
116-
</div>
117-
</label>
118-
<textarea
119-
placeholder="Paste RSA public key here"
120-
value={publicKey}
121-
onChange={(e) => setPublicKey(e.target.value)}
122-
className="mb-6 w-full p-2 border border-gray-600 rounded-md bg-gray-900 text-sm text-white h-32 font-mono"
123-
/>
124-
</>
125-
) : (
99+
{method !== "rsa" && (
126100
<>
127101
<label className="block text-sm font-semibold mb-2 text-gray-300">
128102
<div className="flex items-center">
@@ -144,7 +118,7 @@ export default function EncryptPage() {
144118
<button
145119
onClick={handleEncrypt}
146120
disabled={loading}
147-
className="w-full bg-blue-600 hover:bg-blue-700 text-white py-3 rounded-lg font-semibold transition flex items-center justify-center disabled:opacity-50 disabled:cursor-not-allowed"
121+
className="w-full bg-blue-600 hover:bg-blue-700 text-white py-3 rounded-lg font-semibold transition flex items-center justify-center"
148122
>
149123
<FaLock className="w-4 h-4 mr-2" />
150124
{loading ? "Encrypting..." : "Encrypt"}

0 commit comments

Comments
 (0)