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
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Security in Yandex Cloud
  • Key security principles
  • Division of responsibility
  • Compliance
  • Security measures on the Yandex Cloud side
  • Security tools available to cloud service users
    • All tutorials
      • 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
      • Managing Key Management Service keys with Terraform
      • Encrypting secrets in Terraform
      • Auto Unseal in Hashicorp Vault
      • Secure password transmission to an initialization script
      • Secure storage of GitLab CI passwords as Yandex Lockbox secrets
      • Getting Yandex Lockbox secret value on the GitHub side
      • Getting Yandex Lockbox secret value on the GitLab side
  • User support policy during vulnerability scanning
  • Security bulletins
  • Public IP address ranges

In this article:

  • Getting started
  • Encrypt data
  • Decrypt data
  1. Tutorials
  2. Data encryption and key management
  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 May 13, 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) command line interface 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
© 2025 Direct Cursus Technology L.L.C.