Note: You are looking at a static snapshot of documentation related to Robot Framework automations. The most recent documentation is at https://robocorp.com/docs

RPA.Crypto

Decrypt a file.

Arguments

ArgumentTypeDefault value
pathstrnull
outputstr, NoneNone
encryption_typestr, EncryptionType, NoneNone
param path:Path to encrypted input file
param output:Path to decrypted output file
return:Path to the decrypted file

If no output path is given, it will generate one from the input path. The resulting output path is returned.

Usage

Use encryption key ${key} ${path}= Decrypt file orders.xlsx.enc Log Path to decrypted file is: ${path}

Decrypt a string.

Arguments

ArgumentTypeDefault value
databytes, strnull
encodingstrutf-8
encryption_typestr, EncryptionType, NoneNone
param data:Encrypted data as base64 string
param encoding:Original encoding of string
return:Decrypted string or raw bytes, if None given as encoding

Returns the decrypted string that is parsed with the given encoding, or if the encoding is None the raw bytes are returned.

Usage

Use encryption key ${key} ${text}= Decrypt string ${token} Log Secret string is: ${text}

Encrypt a file.

Arguments

ArgumentTypeDefault value
pathstrnull
outputstr, NoneNone
encryption_typestr, EncryptionType, NoneNone
param path:Path to source input file
param output:Path to encrypted output file
return:Path to the encrypted file

If no output path is given, it will generate one from the input path. The resulting output path is returned.

Usage

Use encryption key ${key} ${path}= Encrypt file orders.xlsx Log Path to encrypted file is: ${path}

Encrypt a string.

Arguments

ArgumentTypeDefault value
textbytes, strnull
encodingstrutf-8
encryption_typestr, EncryptionType, NoneNone
param text:Source text to encrypt
param encoding:Used text encoding
return:Token of the encrypted string in bytes

Usage

Use encryption key ${key} ${token}= Encrypt string This is a secret, don't share it

Generate a Fernet encryption key as base64 string.

Arguments

ArgumentTypeDefault value
encryption_typestr, EncryptionType, NoneNone
return:Generated key as a string

This key can be used for encryption/decryption operations with this library.

NOTE: Store the generated key in a secure place! If the key is lost, the encrypted data can not be recovered. If anyone else gains access to it, they can decrypt your data.

Calculate a hash from a file, in base64 format.

Arguments

ArgumentTypeDefault value
pathstrnull
methodHashSHA1
param path:Path to file
param method:The used hashing method
return:Hash digest of the file

Usage

${digest}= Hash file orders.xlsx method=MD5 Should not be equal ${digest} uSlyRHlbu8NzY29YMZhDUpdErP4=

Calculate a hash from a string, in base64 format.

Arguments

ArgumentTypeDefault value
textstrnull
methodHashSHA1
encodingutf-8
param text:String to hash
param method:Used hashing method
param encoding:Used text encoding
return:Hash digest of the string

Usage

${digest}= Hash string A value that will be hashed Should be equal ${digest} uSlyRHlbu8NzY29YMZhDUpdErP4=

Set key for all following encryption/decryption operations.

Arguments

ArgumentTypeDefault value
keybytes, strnull
encryption_typestr, EncryptionType, NoneNone
param key:Encryption key as base64 string

Assumes the given key has been generated previously using either the keyword Generate Key or with the matching command line utility.

Usage

${key}= Read file encryption.key Use encryption key ${key}

Load an encryption key from Robocorp Vault.

Arguments

ArgumentTypeDefault value
namestrnull
keystr, NoneNone
encryption_typestr, EncryptionType, NoneNone
param name:Name of secret in Vault
param key:Name of encryption key in secret

If the secret only has one value, the key argument is optional.

Usage

# Secret with one value Use encryption key from vault Encryption # Secret with multiple values Use encryption key from vault name=Encryption key=CryptoKey