PALATINELABSDocsENES

Pages

↑↓ to moveEnter to openEsc to close

Base64 package guide

Use Base64 to encode and decode text or file bytes and to generate time-based one-time passwords from a base32 secret.

Version 2.17.1. Installed versions can differ. Examples are illustrative and not tested.

Jump to actions

Prerequisites

The actions run on the Device and need no other application or session. result → x means: save the output in variable x. Fields not marked required are optional and use the default in the table when empty. Invalid Base64, a file you cannot read or a path you cannot write fails the step.

Actions

Base64 Decode (base64Decode)

Decode Base64 into a file. Missing parent folders are created.

Inputs

IDEditor fieldType; default; requirementUse
strBase64Base64 string to be decodedStringdefault ""requiredBase64 text or a String variable.
strTargetPathFile path to be savedStringdefault ""requiredFile to write. The extension does not change the bytes.

Outputs

IDTypeMeaning
resultStringFull path of the written file.

Example

Set strBase64=c2FsdmU= and strTargetPath=samples/decoded.txt. result → writtenPath.

Expected result

The file contains salve. writtenPath is the full path to samples/decoded.txt. If the step fails, parent folders may already exist.

Back to actions

Decode base64 (base64DecodeString)

Decode Base64 into UTF-8 text. Use Base64 Decode for binary content.

Inputs

IDEditor fieldType; default; requirementUse
sourceStringBase64 encoded stringStringdefault ""requiredBase64 text.

Outputs

IDTypeMeaning
resultStringDecoded UTF-8 text.

Example

Set sourceString=c2FsdmU=. result → decoded.

Expected result

decoded is salve. If the bytes are not UTF-8 text, you get replacement characters (�) and no error: use Base64 Decode to a file instead.

Back to actions

Base64 Encode (base64Encode)

Encode all bytes of a file as Base64, with no text conversion.

Inputs

IDEditor fieldType; default; requirementUse
strFilePathFile to be encodedStringdefault ""requiredFile to read.

Outputs

IDTypeMeaning
resultStringBase64 of all file bytes, with no line breaks.

Example

Prepare samples/input.txt that contains only salve, with no line break at the end and no byte order mark. Set strFilePath=samples/input.txt. result → encoded.

Expected result

encoded is c2FsdmU=. Every byte counts, so a line break or byte order mark changes it. An empty file gives "".

Back to actions

Encode base64 (base64EncodeString)

Encode text as UTF-8, then as Base64. A path typed as text is not read as a file.

Inputs

IDEditor fieldType; default; requirementUse
sourceStringSource stringStringdefault ""requiredTyped text or a String variable. UTF-8, with no byte order mark.

Outputs

IDTypeMeaning
resultStringBase64 of the UTF-8 text, with no line breaks.

Example

Set sourceString=salve. result → encoded.

Expected result

encoded is c2FsdmU=. Case, spaces and line breaks change it. Decode base64 gives back the original text.

Back to actions

Generate TOTP (base64GenerateTotp)

Make the current and the next one-time code from a base32 secret. It does not enroll an account or send a code.

Inputs

IDEditor fieldType; default; requirementUse
secretSecret keyCredentialdefault requiredno default (user name and password start empty)Credential whose password is the base32 secret (if empty, the user name is used). A String variable does not work. Case, spaces, hyphens and = do not matter. Not Base64, not a full enrollment link.
algorithmAlgorithmTotpAlgorithmdefault SHA1SHA1⁠, SHA256 or SHA512⁠, as the service uses.
codeDigitsCode digitsNumberdefault 6Whole code length, 6 to 8.
timeStepTime stepNumberdefault 30Period in whole seconds, as the service uses. Usually 30.

Outputs

IDTypeMeaning
currentTOTPStringCode for the current period, leading zeros kept.
nextTOTPStringCode for the next period. The service may refuse it before that period starts.
secondsRemainingNumberWhole seconds until the current period ends, 1 to timeStep⁠, read once when the step runs.

Example

For a test only, prepare Credential variable testTotp with an empty user name and the public test secret GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ in its password field. This secret opens no account. Set secret=$testTotp$, algorithm=SHA1, codeDigits=6 and timeStep=30. Save the outputs in String variables current and next, and Number variable remaining.

Expected result

current and next have six digits each, with leading zeros kept. The codes depend on the Device clock. current is for this 30-second period, next for the one after. remaining is from 1 to 30. Digits outside 6 to 8, a period of 0 or less, an empty secret, or a character that is not base32 fails the step.

Back to actions