- 概述
- 加密
- 数据库
- Java
- Python
- 网页 API
“加密文本”活动,使用对称算法和密钥或使用 PGP 收件人的公钥加密字符串。
UiPath.Cryptography.Activities.EncryptText
描述
使用对称算法和密钥,或使用具有收件人公钥的 PGP 加密字符串。将加密输出作为字符串返回:对于对称算法,返回 Base64;对于 PGP,返回 ASCII 字符。
项目兼容性
Windows - 旧版 | Windows | 跨平台
Windows、跨平台配置
- 算法- 此为下拉菜单,用于选择要使用的加密算法。提供以下选项: AES GCM 、 ChaCha20-Poly1305(非 FIPS) 、 PGP - 相当良好的隐私协议(非 FIPS) 、 AES(已弃用) 、 DES (已弃用) 、 RC2 (非 FIPS)(已弃用) 、 Rijndael (非 FIPS)(已弃用)和TripleDES(已弃用) 。AES GCM和ChaCha20-Poly1305(非 FIPS)是建议为新工作流使用的经过身份验证 (AEAD) 算法。选择“PGP” ,以使用收件人的公钥而不是对称密钥进行加密。
- Text - The text that you want to encrypt. This field supports only strings and
Stringvariables. - 密钥- 要用于加密指定字符串的密钥。仅由对称算法使用。此字段仅支持字符串和
String变量。要以安全字符串而非纯文本形式输入密钥,请选择字段的输入菜单,然后选择“切换到安全输入” - 这将使用密钥安全字符串属性(aSecureString)。
高级选项
选项
- 密钥编码- 用于解释在“密钥”属性中指定的密钥的编码。仅由对称算法使用。下拉列表中列出了计算机上所有可用的文本编码(代码页),首先显示最常见的编码:系统默认值、 Unicode (UTF-8) (默认选项)、 Unicode 、 Unicode (Big-Endian) 、 Unicode (UTF-32 ) 、 Unicode (UTF-32 Big-Endian) 、 US-ASCII和西欧 (ISO) 。列表中遵循其他区域和旧版代码页。
- 文本编码- 用于在加密前将输入文本转换为字节的编码。请设置此选项,以匹配使用密文的第三方工具所需的编码。独立于按键编码- 两者都提供相同的完整文本编码列表,并默认为Unicode (UTF-8) 。仅由对称算法使用。
- Continue On Error - Specifies if the automation should continue even if the activity throws an error. This field only supports Boolean values (
True,False). The default value isFalse. As a result, if the field is blank and an error is thrown, the execution of the project stops. If the value is set toTrue, the execution of the project continues regardless of any error.
对称连线格式和互操作性
这些选项仅适用于对称算法。它们用于生成与外部工具(例如openssl enc 、Java 和 Python)互操作的密文。未设置“连线格式”的现有工作流将继续生成默认的传统输出,该输出保持不变。
- 连线格式- 对称密文布局。可选择以下选项:
- UiPath(传统) (默认)- UiPath 的字节稳定布局(
salt(8) + IV + ciphertext [+ tag],迭代次数为 10,000 次时为 pilot2-HMAC-SHA1)。生成与以前版本相同的输出。 - UiPath (OWASP 2026) - 传统布局,具有更强的 OWASP 建议的 KFS 迭代计数。
- 原始(调用者提供的密钥和 PV) - 调用者提供的密钥和 PV,用于第三方互操作性。要求密钥字节格式为Hex或Base64 。
- OpenSSL ec(Salted__ + VBKFS2-SHA256) - 生成兼容
openssl enc输出。
- UiPath(传统) (默认)- UiPath 的字节稳定布局(
- 密钥字节格式- 如何解释“密钥”字符串。提供以下选项: “Hex”和“Base64” 。当“线格式”为“原始”(调用者提供的密钥和初始化向量)时为必填项;否则,密钥将被视为密码。
- 初始化向量- 当“线格式”为“原始”(调用者提供的密钥和初始化向量)时使用的初始化向量。根据密钥字节格式解读。可选- 将其留空,让密码生成密码。对于所有其他格式,则被拒绝。
- “Kdf 迭代” - pbkdf2 迭代计数。
0使用格式的 OWASP 推荐的默认值( UiPath (OWASP 2026)为 1,300,000, OpenSSL ec为 600,000)。UiPath(传统)和原始数据(调用者提供的密钥和初始化密钥)已被拒绝。 - “AES 密钥大小” - AES 密钥大小(以位为单位)。可用的选项如下: 128 位、 192 位和256 位(默认)。仅当“算法”为“AES”且“传输格式”为OpenSSL ec (Salted__ + PI-SHA256)时适用。必须与对等使用的密钥大小匹配。它不会以传输格式存储,因此加密和解密端必须使用匹配的值。
PGP
当“算法”为“PGP”时,这些选项适用。
- 公钥文件路径- 收件人 PGP 公钥文件的路径。当“算法”为“PGP”时为必需。
- 私钥文件路径- PGP 私钥文件的路径。仅在启用“签名数据”时才需要。
- 密码短语- 签名时用于解锁私钥的密码短语。要将其作为安全字符串而不是纯文本,请选择字段的输入菜单,然后切换到“密码(安全)”输入(a
SecureString)。 - 为数据签名- 启用后,使用您的私钥对加密数据进行签名。该字段仅支持“布尔值”(
True和False)。默认值为False。
输出
- Encrypted Text - Reference to the encrypted text stored in a
Stringvariable for use in other activities.
Windows - 旧版配置
属性面板
常见
- Continue On Error - Specifies if the automation should continue even if the activity throws an error. This field only supports Boolean values (
True,False). The default value isFalse. As a result, if the field is blank and an error is thrown, the execution of the project stops. If the value is set toTrue, the execution of the project continues regardless of any error.备注:如果“Try Catch 异常处理”中包含该活动且“出错时继续”属性的值为“
True”,则系统在执行项目时不会捕获任何错误。 - “显示名称”- 活动的显示名称。
输入
-
Algorithm - A drop-down menu which enables you to select the encryption algorithm you want to use. The following options are available: AES (Deprecated), AES GCM, DES (Deprecated), RC2 (Non-FIPS) (Deprecated), Rijndael (Non-FIPS) (Deprecated), and TripleDES.
备注:使用AES GCM算法时,解密输入必须以(连接的字节)格式提供:
Salt (8bytes) + IV (12 bytes) + encryptedData (variable bytes) + Tag (16 bytes)。该活动还使用以下参数:- PBKDF2 迭代计数为 10000
- 生成的密钥为 256 位(32 字节)
请注意,256 位生成的密钥与“密钥输入”选项不同。
-
编码- 用于解释在密钥属性中指定的输入文本和密钥的编码。此字段仅支持
Encoding变量。有关此变量类型的更多信息,请查看Microsoft 官方文档。 -
Key - The key that you want to use to encrypt the specified string. This field supports only strings and
Stringvariables. -
Key Secure String - The secure string used to encrypt the input string.
-
Text - The text that you want to encrypt. This field supports only strings and
Stringvariables.
其他
- “私有”- 选中后将不再以“Verbose”级别记录变量和参数的值。
输出
- Result - The encrypted text, stored in a
Stringvariable.