Closed
Description
Summary of the new feature/enhancement
As a user I would like New-Guid
to accept an optional custom byte array at creation time, allowing me to control the bytes that are used to create the Guid object.
Proposed technical implementation details (optional)
For example something like...
$Bytes = [System.Byte[]]::new(16)
$RNG = [System.Security.Cryptography.RNGCryptoServiceProvider]::new()
$RNG.GetBytes($Bytes)
$VersionByteIndex = [System.BitConverter]::IsLittleEndian ? 7 : 6
$Bytes[$VersionByteIndex] = $Bytes[$VersionByteIndex] -band [char]0x0F -bxor [char]0x40
$Bytes[9] = $Bytes[9] -band 0x3F -bxor 0x80
New-Guid -Bytes $Bytes
The underlying c# implementation would have a code path that calls new Guid(Byte[])
.
Also if you want to ensure that the result is v4 RFC 4122 compliant then some sort of validation would be needed.