22 lines
908 B
PowerShell
22 lines
908 B
PowerShell
# Script de génération des fichiers Key.txt et mots de passe chiffrés
|
|
$Scriptlocation = Split-Path -Path $MyInvocation.MyCommand.Path
|
|
|
|
# Générer une clé aléatoire (24 octets pour 192 bits)
|
|
$keyBytes = New-Object Byte[] 24
|
|
[Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($keyBytes)
|
|
$keyString = [Convert]::ToBase64String($keyBytes)
|
|
$keyString | Out-File "$Scriptlocation\Key.txt" -Encoding UTF8
|
|
|
|
# Mot de passe commun
|
|
$password = "crhdf!@2026"
|
|
|
|
# Utilisateurs à traiter
|
|
$users = @("supporthdf", "adminlyc")
|
|
|
|
foreach ($user in $users) {
|
|
# Chiffrer le mot de passe avec la clé
|
|
$encryptedPassword = ConvertTo-SecureString $password -AsPlainText -Force | ConvertFrom-SecureString -Key $keyBytes
|
|
$encryptedPassword | Out-File "$Scriptlocation\$user-CryptPwd.txt" -Encoding UTF8
|
|
}
|
|
|
|
Write-Host "Fichiers générés : Key.txt et fichiers chiffrés pour supporthdf et adminlyc" |