Skip to content

Commit

Permalink
new file: src/Sicurezza/GeneraPasswordSicura.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
gpicchiarelli committed Mar 19, 2024
1 parent 3a9f4ad commit 37ce924
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Sicurezza/GeneraPasswordSicura.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
param(
[Parameter(Mandatory=$true)]
[int]$Lunghezza
)

# Definisci i caratteri validi per la password
$caratteriValidi = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[]{}|;:'\,.<>?/`~"
$password = ""

# Crea un oggetto Random
$random = New-Object System.Random

# Genera la password
for ($i = 0; $i -lt $Lunghezza; $i++) {
$randomIndex = $random.Next(0, $caratteriValidi.Length)
$password += $caratteriValidi[$randomIndex]
}

# Stampa la password generata
Write-Output $password

0 comments on commit 37ce924

Please sign in to comment.