Skip to content

ConvertTo-SodiumSealedBox

SYNOPSIS

Encrypts a message using a sealed public key box.

SYNTAX

__AllParameterSets

ConvertTo-SodiumSealedBox [-Message] <string> [-PublicKey] <string> [<CommonParameters>]

ALIASES

This cmdlet has the following aliases, {{Insert list of aliases}}

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: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 0
  IsRequired: true
  ValueFromPipeline: true
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-PublicKey

The base64-encoded public key used for encryption.

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 1
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.String

{{ Fill in the Description }}

OUTPUTS

System.String

{{ Fill in the Description }}

NOTES

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