New-SodiumKeyPair¶
SYNOPSIS¶
Generates a new Sodium key pair.
SYNTAX¶
NewKeyPair (Default)¶
New-SodiumKeyPair [-ProgressAction <ActionPreference>] [<CommonParameters>]
SeededKeyPair¶
New-SodiumKeyPair -Seed <String> [-ProgressAction <ActionPreference>] [<CommonParameters>]
DESCRIPTION¶
This function creates a new cryptographic key pair using Sodium's PublicKeyBox. The keys are returned as a PowerShell custom object, with both the public and private keys encoded in base64 format.
If a seed is provided, the key pair is deterministically generated using a SHA-256 derived seed. This ensures that the same input seed will always produce the same key pair.
EXAMPLES¶
EXAMPLE 1¶
New-SodiumKeyPair
Output:
PublicKey PrivateKey
--------- ----------
Ac0wdsq6lqLGktckJrasPcTbVRuUCU+OKzVpMno+v0g= PVXI64v00+aT2b2O6Q4l+SfMBUY2R/Nogsl2mp/hXAs=
Generates a new key pair and returns a custom object containing the base64-encoded public and private keys.
EXAMPLE 2¶
New-SodiumKeyPair -Seed "MySecureSeed"
Output:
PublicKey PrivateKey
--------- ----------
WQakMx2mIAQMwLqiZteHUTwmMP6mUdK2FL0WEybWgB8= ci5/7eZ0IbGXtqQMaNvxhJ2d9qwFxA8Kjx+vivSTXqU=
Generates a deterministic key pair using the given seed string. The same seed will produce the same key pair every time.
EXAMPLE 3¶
"MySecureSeed" | New-SodiumKeyPair
Output:
PublicKey PrivateKey
--------- ----------
WQakMx2mIAQMwLqiZteHUTwmMP6mUdK2FL0WEybWgB8= ci5/7eZ0IbGXtqQMaNvxhJ2d9qwFxA8Kjx+vivSTXqU=
Generates a deterministic key pair using the given seed string via pipeline. The same seed will produce the same key pair every time.
PARAMETERS¶
-Seed¶
A seed value to use for key generation.
Type: String
Parameter Sets: SeededKeyPair
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
-ProgressAction¶
{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters¶
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS¶
OUTPUTS¶
PSCustomObject¶
NOTES¶
Returns a PowerShell custom object with the following properties: - PublicKey: The base64-encoded public key. - PrivateKey: The base64-encoded private key. If key generation fails, an exception is thrown.
RELATED LINKS¶
https://psmodule.io/Sodium/Functions/New-SodiumKeyPair/
https://doc.libsodium.org/public-key_cryptography/public-key_signatures