Skip to content

Instantly share code, notes, and snippets.

View fearspear's full-sized avatar

Amar Khanna fearspear

View GitHub Profile
@fearspear
fearspear / crypto.js
Last active January 6, 2024 12:00
Generate a Secure Random Password Using Web Crypto API and Javascript
// Check if the Crypto API is available
if (window.crypto && window.crypto.getRandomValues) {
// Crypto API is available
} else {
// Crypto API is not supported, provide alternative method
console.error("Crypto API not supported in this browser.");
}
// Function to generate a secure random password
function generateRandomPassword(length, includeUppercase, includeLowercase, includeNumbers, includeSpecialChars) {