#Cryptification of files and text
This time, I will explain how to encrypt files and text data.
📄️ Decryption of files and text
There are some actions related to security and encryption.This section describes how to decrypt encrypted text data.
📄️ Calculation of hash values
This section describes how to have a hash of text and file data and calculate the hash value.
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 name | value |
---|---|
Encoding | Character string for the character string to be created |
Encryption text | Target text to be encrypted |
Encryption key | Password used for encryption |
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
From "Search for action", enter "Encrypt text in AES".
Set the parameter as follows
Parameter name value Encoding UTF-8 Encryption text %"Text data to be encrypted"% Encryption key Password used for encryption 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 name | value |
---|---|
Encoding | Character string for the character string to be created |
Encrypted file | Target file to be encrypted |
Encryption key | Password used for encryption |
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
Enter "Aes encrypted from file in Aes" from "Search Azu".
Set the parameter as follows
Parameter name value Encoding UTF-8 Encryption text C:\Users\Public\Documents\document.txt Encryption key Password used for encryption 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.