* adds basic module layout * fix module manifest encoding * fix callsign in appveyor helper * adds challenge file related functions * adds connection manager functions * adds Test-ChallengeFile * adds item related functions * adds store related functions * adds cSpell dictionary * adds CredentialStore related Pester tests * [WIP] test Pester file * fix typo * adds file dependencies * [WIP] fix pester tests * fix exception state * [WIP] add file dependencies * fix gitkeep filename * set constant debug module version string * adds Pester Tests for New-CredentialStoreItem * adds basic readme file * adds functions to export; adds meta data * adds vscode debug config * adds test for optional dependencies * [WIP] Implements optional dependency test * adds taskrunner definitions * adds CBH * add gitignore file * adds basic Build tasks * typo fixed * adds build folder to ignore list * adds Cisco and NetApp opt dependencies * adds build task * fix end of line dequence * remove task.json error * adds sources for optional modules * enables Pester and posh-git * prepare pre-release
48 lines
1.0 KiB
PowerShell
48 lines
1.0 KiB
PowerShell
function Get-RandomKey {
|
|
<#
|
|
.SYNOPSIS
|
|
Returns a random key
|
|
|
|
.DESCRIPTION
|
|
You can use the key for further use with SecureStrings.
|
|
|
|
.PARAMETER Size
|
|
Define the key size. You can choose between 16, 24 and 32
|
|
|
|
.INPUTS
|
|
[None]
|
|
|
|
.OUTPUTS
|
|
Returns a Random key as [Byte[]] array.
|
|
|
|
.EXAMPLE
|
|
.\Get-RandomKey -Size 24
|
|
|
|
.NOTES
|
|
File Name : Get-RandomKey.ps1
|
|
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
Requires :
|
|
|
|
.LINK
|
|
https://github.com/OCram85/PSCredentialStore
|
|
#>
|
|
|
|
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[ValidateSet(16, 24, 32)]
|
|
[string]$size
|
|
)
|
|
# Init the vars
|
|
[Byte[]]$Key = @()
|
|
$i = 0
|
|
|
|
while ($i -ne $size) {
|
|
$element = Get-Random -Minimum 0 -Maximum 255
|
|
Write-Debug ("The current element is {0}." -f $element)
|
|
$Key += $element
|
|
$i++
|
|
}
|
|
$Key
|
|
}
|