PSCredentialStore/src/Helper/Get-RandomKey.ps1
Marco Blessing 599232ecec Implements CisServer connection handling (#10)
### fixes #8 

- gh deployment for dev branch removed
  - duplicate deployment.
  - see appveyor artifacts.
- installation of dependencies moved to ps function
- modularize PSGallery Deployment branch
- update platPS docs
- enable private build
- Implements ConnectionType CisServer (#9)
2017-10-23 10:53:52 +02:00

50 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
}