Private/Share/ConvertFrom-SecretSharingWordIndex.ps1
|
function ConvertFrom-SecretSharingWordIndex { <# .SYNOPSIS Combines a most-significant-digit-first array of base-2^RadixBit digits back into a single non-negative big integer. #> [CmdletBinding()] [OutputType([System.Numerics.BigInteger])] param( [Parameter(Mandatory)] [int[]]$Index, [Parameter(Mandatory)] [ValidateRange(1, 31)] [int]$RadixBit ) $radix = [System.Numerics.BigInteger]::Pow(2, $RadixBit) $value = [System.Numerics.BigInteger]::Zero foreach ($d in $Index) { $value = ($value * $radix) + $d } return $value } |