Mengenkripsi teks biasa menggunakan CMK simetris.
Deskripsi operasi
Precautions
-
For information about the access policy required to allow a RAM user or RAM role to use this operation, see Resource Access Management.
-
This operation is accessible through a shared gateway or a dedicated gateway. For more information, see Alibaba Cloud SDK.
-
Shared gateway: You can access KMS over the Internet or a VPC. To use this method, you must enable Internet access. For more information, see Access keys in a KMS instance over the Internet.
-
Dedicated gateway: You can access KMS using the private endpoint of KMS (
<YOUR_KMS_INSTANCE_ID>.cryptoservice.kms.aliyuncs.com).
-
QPS limits
-
When accessed through a shared gateway, the queries per second (QPS) limit for a single user is 1,000. If the limit is exceeded, requests are throttled, which can affect your business. We recommend that you stay within this limit to avoid throttling.
-
When accessed through a dedicated gateway, the QPS limit for a single user is subject to the computing performance specifications of your KMS instance. For more information, see Performance metrics.
Description
-
KMS encrypts the specified data using the primary version of a specified key.
-
You can encrypt a maximum of 6 KB of data, such as an RSA key, a database password, or other sensitive information.
-
If you migrate encrypted data from one region to another, you can call the Encrypt operation in the destination region to re-encrypt the plaintext data key from the source region. This generates a new encrypted data key. You can then call the Decrypt operation to decrypt this new key in the destination region.
Coba sekarang
Test
RAM authorization
Parameter permintaan
|
Parameter |
Type |
Required |
Description |
Example |
| KeyId |
string |
Yes |
ID kunci. Anda juga dapat menentukan alias atau Nama Sumber Daya Alibaba Cloud (ARN) kunci. Untuk informasi selengkapnya tentang alias, lihat Manage aliases. Catatan
Saat Anda mengakses kunci di akun Alibaba Cloud lain, Anda harus menentukan ARN kunci. ARN kunci dalam format |
key-hzz630494463ejqjx**** |
| Plaintext |
string |
Yes |
Teks biasa yang akan dienkripsi. Teks biasa harus dienkode Base64. |
SGVsbG8gd29y**** |
| EncryptionContext |
object |
No |
String JSON yang terdiri dari pasangan kunci-nilai. Jika Anda menentukan parameter ini, Anda harus menentukan parameter yang sama saat memanggil operasi Decrypt. Untuk informasi selengkapnya, lihat EncryptionContext. |
{"Example":"Example"} |
| DryRun |
string |
No |
Apakah akan mengaktifkan fitur dry run.
Fitur dry run digunakan untuk menguji panggilan API dan memverifikasi izin pada Sumber daya yang Anda miliki serta validitas parameter permintaan. Anda dapat melihat hasil pemeriksaan di tanggapan.
|
false |
Elemen respons
|
Element |
Type |
Description |
Example |
|
object |
|||
| KeyVersionId |
string |
The ID of the key version that is used to encrypt the plaintext. It is the primary version of the specified key. |
86a9efd9-3d16-4894-bd4f-1fc43f3f**** |
| KeyId |
string |
The ID of the key. If you use an alias or an ARN of the key in the request, the ID of the key is returned. |
key-hzz630494463ejqjx**** |
| CiphertextBlob |
string |
The ciphertext of the data that is encrypted using the primary version of the specified key. |
DZhOWVmZDktM2QxNi00ODk0LWJkNGYtMWZjNDNmM2YyYWJmaaSl+TztSIMe43nbTH/Z1Wr4XfLftKhAciUmDQXuMRl4WTvKhxjMThjK**** |
| RequestId |
string |
The ID of the request, which is a unique identifier generated by Alibaba Cloud for the request. You can use the ID to troubleshoot issues. |
475f1620-b9d3-4d35-b5c6-3fbdd941423d |
Contoh
Respons sukses
JSONformat
{
"KeyVersionId": "86a9efd9-3d16-4894-bd4f-1fc43f3f****",
"KeyId": "key-hzz630494463ejqjx****",
"CiphertextBlob": "DZhOWVmZDktM2QxNi00ODk0LWJkNGYtMWZjNDNmM2YyYWJmaaSl+TztSIMe43nbTH/Z1Wr4XfLftKhAciUmDQXuMRl4WTvKhxjMThjK****",
"RequestId": "475f1620-b9d3-4d35-b5c6-3fbdd941423d"
}
Kode kesalahan
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParameter | The specified parameter is invalid. | An invalid value is specified for the parameter. |
| 404 | Forbidden.KeyNotFound | The specified Key is not found. | The error message returned because the specified CMK does not exist. |
| 404 | Forbidden.AliasNotFound | The specified Alias is not found. | The error message returned because the specified alias does not exist. |
| 404 | InvalidAccessKeyId.NotFound | The Access Key ID provided does not exist in our records. |
Lihat Error Codes untuk daftar lengkap.
Catatan rilis
Lihat Release Notes untuk daftar lengkap.