Decrypt File

Decrypt a file.

Arguments

Argument Type Default value Description
path strPath to encrypted input file
output str NonePath to decrypted output file
param path:Path to encrypted input file
param output:Path to decrypted output file

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

Examples

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

Decrypt String

Decrypt a string.

Arguments

Argument Type Default value Description
data typing.Union[str, bytes]Encrypted data as base64 string
encodingutf-8Original encoding of string
param data:Encrypted data as base64 string
param encoding:Original encoding of string

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

Examples

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

Encrypt File

Encrypt a file.

Arguments

Argument Type Default value Description
path strPath to source input file
output str NonePath to encrypted output file
param path:Path to source input file
param output:Path to encrypted output file

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

Examples

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

Encrypt String

Encrypt a string.

Arguments

Argument Type Default value Description
text typing.Union[str, bytes]Source text to encrypt
encodingutf-8Used text encoding
param text:Source text to encrypt
param encoding:Used text encoding

Examples

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

Generate Key

Generate a Fernet encryption key as base64 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.

Hash File

Calculate a hash from a file, in base64 format.

Arguments

Argument Type Default value Description
path strPath to file
method Hash { MD5 | SHA1 | SHA224 | SHA256 | ... } Hash.SHA1The used hashing method
param path:Path to file
param method:The used hashing method

Examples

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

Hash String

Calculate a hash from a string, in base64 format.

Arguments

Argument Type Default value Description
text strString to hash
method Hash { MD5 | SHA1 | SHA224 | SHA256 | ... } Hash.SHA1Used hashing method
encodingutf-8Used text encoding
param text:String to hash
param method:Used hashing method
param encoding:Used text encoding

Examples

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

Use Encryption Key

Set key for all following encryption/decryption operations.

Arguments

Argument Type Default value Description
key strEncryption key as base64 string
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.

Examples

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

Use Encryption Key From Vault

Load an encryption key from Robocorp Vault.

Arguments

Argument Type Default value Description
name strName of secret in Vault
key str NoneName of encryption key in secret
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.

Examples

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