Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Tutorials
    • All tutorials
    • Differentiation of access permissions for user groups
    • Creating an L7 load balancer with a Smart Web Security security profile through an Application Load Balancer Ingress controller
    • Centralized online publication and app protection against DDoS attacks
    • Delivering logs from a VM instance to Cloud Logging
    • Writing load balancer logs to PostgreSQL
    • Secure storage of GitLab CI passwords as Yandex Lockbox secrets
    • Service account with an OS Login profile for VM management via Ansible
    • Transferring logs from Container Optimized Image to Cloud Logging
    • Adding an HTML page to work with SmartCaptcha
    • Creating an L7 load balancer with a security profile
    • Alert settings in Monitoring
    • Exporting audit logs to MaxPatrol SIEM
    • Exporting audit logs to SIEM Splunk systems
    • Uploading audit logs to ArcSight SIEM
      • Which encryption method should I choose?
      • Encrypting data using the Yandex Cloud CLI and API
      • Encrypting data using the Yandex Cloud SDK
      • Encrypting data using the AWS Encryption SDK
      • Encrypting data using Google Tink
    • Server-side encryption for an Object Storage bucket
    • Encrypting secrets in Hashicorp Terraform
    • Managing KMS keys with Hashicorp Terraform
    • Auto Unseal in Hashicorp Vault

In this article:

  • Getting started
  • Encrypt data
  • Decrypt data
  1. Security
  2. Data encryption
  3. Encrypting data using the Yandex Cloud CLI and API

Encrypting data using the Yandex Cloud CLI and API

Written by
Yandex Cloud
Updated at February 12, 2025
  • Getting started
  • Encrypt data
  • Decrypt data

In Yandex Key Management Service, you can encrypt and decrypt small amounts of data (up to 32 KB). For more information about the available encryption methods, see Which encryption method should I choose?.

Getting startedGetting started

If you do not have the Yandex Cloud CLI yet, install and initialize it.

Encrypt dataEncrypt data

CLI
API

This command will encrypt the plain text provided in --plaintext-file and write the resulting ciphertext to --ciphertext-file:

  • --id: ID of the KMS key. Make sure you set either the --id or --name flag.
  • --name: Name of the KMS key. Make sure you set either the --id or --name flag.
  • --version-id (optional): Version of the KMS key to use for encryption. The primary version is used by default.
  • --plaintext-file: Input file with plaintext.
  • --aad-context-file (optional): Input file with AAD context.
  • --ciphertext-file: Output file with ciphertext.
yc kms symmetric-crypto encrypt \
  --id abj76v82fics******** \
  --plaintext-file plaintext-file \
  --ciphertext-file ciphertext-file

To encrypt data, use the encrypt REST API method for the SymmetricCrypto resource or the SymmetricCryptoService/Encrypt gRPC API call.

Decrypt dataDecrypt data

CLI
API

This command will decrypt the ciphertext provided in --ciphertext-file and write the resulting plain text to --plaintext-file:

  • --id: ID of the KMS key. Make sure you set either the --id or --name flag.
  • --name: Name of the KMS key. Make sure you set either the --id or --name flag.
  • --ciphertext-file: Input file with plaintext.
  • --aad-context-file (optional): Input file with AAD context.
  • --plaintext-file: Output file with ciphertext.
yc kms symmetric-crypto decrypt \
  --id abj76v82fics******** \
  --ciphertext-file ciphertext-file \
  --plaintext-file decrypted-file

To decrypt data, use the decrypt REST API method for the SymmetricCrypto resource or the SymmetricCryptoService/Decrypt gRPC API call.

See alsoSee also

  • Command line interface CLI.
  • Symmetric encryption in Yandex Key Management Service.
  • Asymmetric encryption in Yandex Key Management Service.
  • Managing keys in Key Management Service.

Was the article helpful?

Previous
Which encryption method should I choose?
Next
Encrypting data using the Yandex Cloud SDK
Yandex project
© 2025 Yandex.Cloud LLC