Marco Blessing
7708df9b66
* update pwsh style in store files * update pwsh style in item files * update pwsh style in connection files * update pwsh style in certificate files * update pwsh style in private files * update pwsh style in drone helper * update meta * fix pwsh style * fix output type * fix typo in OutputType * update appveyor build mode * debugging build mode * wip * test windows pipeline * fix typo * simplify drone setup * update readme * remove deprecated cicd setup * update pwsh style
37 lines
706 B
PowerShell
37 lines
706 B
PowerShell
function Get-RandomAESKey {
|
|
<#
|
|
.SYNOPSIS
|
|
Generate a new 32-byte AES key.
|
|
|
|
.DESCRIPTION
|
|
Uses the System.Security.Cryptography namespace for random aes key generation.
|
|
|
|
.INPUTS
|
|
[None]
|
|
|
|
.OUTPUTS
|
|
[byte[]]
|
|
|
|
.EXAMPLE
|
|
.\Get-RandomAESKey
|
|
#>
|
|
|
|
[CmdletBinding()]
|
|
[OutputType([byte[]])]
|
|
param ()
|
|
|
|
begin {}
|
|
|
|
process {
|
|
$key = [byte[]]::new(32)
|
|
$rng = [System.Security.Cryptography.RNGCryptoServiceProvider]::Create()
|
|
$rng.GetBytes($key)
|
|
Write-Output $key
|
|
if ($null -ne $key) {
|
|
[array]::Clear($key, 0, $key.Length)
|
|
}
|
|
|
|
}
|
|
end {}
|
|
}
|