Skip to main content

#Cryptification of files and text

This time, I will explain how to encrypt files and text data.

Cryptence technology and precautions

This time, we use AES encryption technology.

It is still a technology that is still used in many environments, and is also used to connect with WiFi router and terminal.

It is difficult to analyze at a brute force, and if the key length is set to 256 bits, analysis is said to take several hundred trillion years.

It is classified into a common key code, and requires the same password for decay and decryptation.

Therefore, if thepassword is lost, the data will not be able to decrypt to the original state.

If you use Power Automate Desktop with AES, be sure to refrain from password for decrypt.

In addition, as I will explain the method of decoding this time, it is very difficult to analyze at the braid hit as mentioned above.

Even if you forget your password, you know the encryption algorithm, and if the number of digits in the password is small, you may be able to decod the number of digits is not very realistic.

To encrypt a specific text data

When encrypting on -premises software or specific string information obtained from the web, use an action called "Encrypt text with AES".

Details of action "Encrypt text in AES"

The action has the following parameters.

Parameter namevalue
EncodingCharacter string for the character string to be created
Encryption textTarget text to be encrypted
Encryption keyPassword used for encryption

action

Implement a sample flow with copy and paste

As a sample, we have prepared a flow that encrypts text data and save results in a file.

Copy the following code and paste it on the edit screen of Power Automate Desktop to add the target action.

Since the encryption password information is not taken over between the machines, change the encryption part of the added action to any password.

SET TargetString TO $'''%'Target text to be encrypted'%'''
Cryptography.EncryptText.EncryptTextWithAES Encoding: Cryptography.EncryptionEncoding.UTF8 TextToEncrypt: TargetString EncryptionKey: `` PaddingMode: Cryptography.PaddingMode.PKCS7 KeySize: Cryptography.AESKeySize.Bits256 EncryptedText=> EncryptedText
File.WriteText File: $'''C:\\Users\\Public\\Documents\\encrypted.txt''' TextToWrite: EncryptedText AppendNewLine: True IfFileExists: File.IfFileExists.Overwrite Encoding: File.FileEncoding.UTF8

When you execute it, you can save a text file encrypted in the public document.

Operate and implement Power Automate Desktop

  1. From "Search for action", enter "Encrypt text in AES".

  2. Set the parameter as follows

    Parameter namevalue
    EncodingUTF-8
    Encryption text%"Text data to be encrypted"%
    Encryption keyPassword used for encryption
  3. By execution, the specified string is encrypted using AES.

Exceptions that can occur

If the encryption setting is not appropriate or contains unsupported character strings, an error may occur during encryption.

We recommend that you implement block processing.

To encrypt specific file data

If you get information from a specific file and encrypt it, use an action called "Encrypt from a file in Aes".

Details of "encrypted from file in AES" action

The action has the following parameters.

Parameter namevalue
EncodingCharacter string for the character string to be created
Encrypted fileTarget file to be encrypted
Encryption keyPassword used for encryption

action

In the description

Aes encrypts the content of the file.

It is easy to misunderstand because it is, but this action does not overwrite the referenced file.

The result after encryption is stored as a variable.

Implement a sample flow with copy and paste

As a sample, we have prepared a flow that encrypts text files stored in public documents and create created strings as another text file.

Copy the following code and paste it on the edit screen of Power Automate Desktop to add the target action.

Since the encryption password information is not taken over between the machines, change the encryption part of the added action to any password.

Cryptography.EncryptFromFile.EncryptFromFileWithAES Encoding: Cryptography.EncryptionEncoding.Unicode FileToEncrypt: $'''C:\\Users\\Public\\Documents\\document.txt''' EncryptionKey: `` PaddingMode: Cryptography.PaddingMode.PKCS7 KeySize: Cryptography.AESKeySize.Bits256 EncryptedText=> EncryptedText
File.WriteText File: $'''C:\\Users\\Public\\Documents\\encrypted.txt''' TextToWrite: EncryptedText AppendNewLine: True IfFileExists: File.IfFileExists.Overwrite Encoding: File.FileEncoding.UTF8

Operate and implement Power Automate Desktop

  1. Enter "Aes encrypted from file in Aes" from "Search Azu".

  2. Set the parameter as follows

    Parameter namevalue
    EncodingUTF-8
    Encryption textC:\Users\Public\Documents\document.txt
    Encryption keyPassword used for encryption
  3. By execution, the text data of the specified file is encrypted and the result is stored as a variable.

Exceptions that can occur

An error may occur during encryption.

We recommend that you implement block processing.