Skip to content

ConvertTo-SodiumSealedBox

SYNOPSIS

Encrypts a message using a sealed public key box.

SYNTAX

ConvertTo-SodiumSealedBox [-Message] <String> [-PublicKey] <String> [-ProgressAction <ActionPreference>]
 [<CommonParameters>]

DESCRIPTION

This function encrypts a given message using a public key with the SealedPublicKeyBox method from the Sodium library. The result is a base64-encoded sealed box that can only be decrypted by the corresponding private key.

EXAMPLES

EXAMPLE 1

ConvertTo-SodiumSealedBox -Message "Hello world!" -PublicKey $publicKey

Output:

hhCon4PO1X0TIPeh1i4GM6Wg9HSF5ge/x4L7p1vNd3lIdiJqNmBfswkcHipyM4HUr9wDLebjARVp5tsB

Encrypts the message "Hello world!" using the provided base64-encoded public key and returns a base64-encoded sealed box.

EXAMPLE 2

"Sensitive Data" | ConvertTo-SodiumSealedBox -PublicKey $publicKey

Output:

p3PGL162uLCvrsCRLUDrc/Kfc5biGVzxRDg25ZdJoR9Y6ABZUKo8pvDoOGdchv0iBYQO2LP0Q6BkVbIDBUw=

Uses pipeline input to encrypt the provided message using the specified public key.

PARAMETERS

-Message

The message string to be encrypted.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-PublicKey

The base64-encoded public key used for encryption.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
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

System.String

NOTES

The function returns a base64-encoded sealed box string that can only be decrypted by the corresponding private key.

https://psmodule.io/Sodium/Functions/ConvertTo-SodiumSealedBox/

https://doc.libsodium.org/public-key_cryptography/sealed_boxes