From f029c222f94627845d52c2638de9725f8d71ea13 Mon Sep 17 00:00:00 2001 From: Adil Sadqi <42699429+AdilSadqi@users.noreply.github.com> Date: Sun, 7 Apr 2024 00:31:46 +0000 Subject: [PATCH] Update main.js.download --- index_files/main.js.download | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/index_files/main.js.download b/index_files/main.js.download index a85b606..d36b0cb 100644 --- a/index_files/main.js.download +++ b/index_files/main.js.download @@ -245,20 +245,29 @@ function commander(cmd) { break; case "pin": - // Function to generate a random 8-digit PIN - function generatePIN() { + // Function to generate a random PIN with a specified number of digits + function generatePIN(numDigits) { var pin = ""; - for (var i = 0; i < 8; i++) { + for (var i = 0; i < numDigits; i++) { pin += Math.floor(Math.random() * 10); // Append a random digit (0-9) to the PIN } return pin; } - // Call the generatePIN function to get the PIN - var generatedPIN = generatePIN(); + // Prompt the user to enter the number of digits for the PIN + var numDigits = prompt("Enter the number of digits for the PIN:"); - // Display the generated PIN - addLine("Your generated PIN is: " + generatedPIN, "color2", 80); + // Validate the input + if (numDigits && !isNaN(numDigits) && parseInt(numDigits) > 0) { + // Call the generatePIN function with the specified number of digits + var generatedPIN = generatePIN(parseInt(numDigits)); + + // Display the generated PIN + addLine("Your generated PIN is: " + generatedPIN, "color2", 80); + } else { + // Display an error message if the input is invalid + addLine("Invalid input. Please enter a valid number of digits.", "color2", 80); + } break; case "sudo":