scripts

ConvertTo-Base64.ps1

SYNOPSIS

Converts bytes or text to base64-encoded text.

SYNTAX

BinaryData

ConvertTo-Base64.ps1 [-Data] <Byte[]> [-UriStyle] [-ProgressAction <ActionPreference>] [<CommonParameters>]

TextData

ConvertTo-Base64.ps1 [-Text] <String> [[-Encoding] <String>] [-UriStyle] [-ProgressAction <ActionPreference>]
 [<CommonParameters>]

DESCRIPTION

EXAMPLES

EXAMPLE 1

ConvertTo-Base64.ps1 'username:BadP@ssword' utf8

dXNlcm5hbWU6QmFkUEBzc3dvcmQ=

PARAMETERS

-Data

Binary data to convert.

Type: Byte[]
Parameter Sets: BinaryData
Aliases:

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

-Text

Text data to convert.

Type: String
Parameter Sets: TextData
Aliases:

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

-Encoding

The text encoding to use when converting text to binary data.

Type: String
Parameter Sets: TextData
Aliases:

Required: False
Position: 2
Default value: Utf8
Accept pipeline input: False
Accept wildcard characters: False

-UriStyle

Indicates that the URI-friendly variant of the base64 algorithm should be used. This variant, as used by JWTs, uses - instead of +, and _ instead of /, and trims the = padding at the end to avoid extra escaping within URLs or URL-encoded data.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

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

System.String or System.Byte[] of data to base64-encode.

OUTPUTS

System.String containing the base64-encoded data.

NOTES

https://docs.microsoft.com/dotnet/api/system.convert.tobase64string