Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • Wolfram Notebook Assistant + LLM Kit

    All-in-one AI assistance for your Wolfram experience

  • System Modeler
  • Wolfram Player
  • Finance Platform
  • Wolfram Engine
  • Enterprise Private Cloud
  • Application Server
  • Wolfram|Alpha Notebook Edition
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • AI & Linguistic Understanding

Deployment Options

  • Wolfram Cloud
  • wolframscript
  • Wolfram Engine Community Edition
  • Wolfram LLM API
  • WSTPServer
  • Wolfram|Alpha APIs

From the Community

  • Function Repository
  • Community Paclet Repository
  • Example Repository
  • Neural Net Repository
  • Prompt Repository
  • Wolfram Demonstrations
  • Data Repository
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

  • Data & Computational Intelligence
  • Model-Based Design
  • Algorithm Development
  • Wolfram|Alpha for Business
  • Blockchain Technology
  • Education Technology
  • Quantum Computation

WolframConsulting.com

Wolfram Solutions

  • Data Science
  • Artificial Intelligence
  • Biosciences
  • Healthcare Intelligence
  • Sustainable Energy
  • Control Systems
  • Enterprise Wolfram|Alpha
  • Blockchain Labs

More Wolfram Solutions

Wolfram Solutions For Education

  • Research Universities
  • Colleges & Teaching Universities
  • Junior & Community Colleges
  • High Schools
  • Educational Technology
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM/STEAM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
Wolfram|Alpha
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • Wolfram Notebook Assistant + LLM Kit
    • System Modeler
    • Wolfram Player
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Wolfram Engine
    • Enterprise Private Cloud
    • Application Server
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • AI & Linguistic Understanding
    • Deployment Options
      • Wolfram Cloud
      • wolframscript
      • Wolfram Engine Community Edition
      • Wolfram LLM API
      • WSTPServer
      • Wolfram|Alpha APIs
    • From the Community
      • Function Repository
      • Community Paclet Repository
      • Example Repository
      • Neural Net Repository
      • Prompt Repository
      • Wolfram Demonstrations
      • Data Repository
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions

    We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

    WolframConsulting.com

    Wolfram Solutions

    • Data Science
    • Artificial Intelligence
    • Biosciences
    • Healthcare Intelligence
    • Sustainable Energy
    • Control Systems
    • Enterprise Wolfram|Alpha
    • Blockchain Labs

    More Wolfram Solutions

    Wolfram Solutions For Education

    • Research Universities
    • Colleges & Teaching Universities
    • Junior & Community Colleges
    • High Schools
    • Educational Technology
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM/STEAM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • Wolfram|Alpha
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
Encrypt
  • See Also
    • Decrypt
    • EncryptFile
    • EncryptedObject
    • SymmetricKey
    • GenerateSymmetricKey
    • GenerateAsymmetricKeyPair
    • GenerateDigitalSignature
    • Hash
    • FieldMasked
    • CellularAutomaton
    • ShiftRegisterSequence
    • BinarySerialize
    • AuthenticationDialog
  • Related Guides
    • Cryptography
    • Systems-Related String Operations
    • Discrete Mathematics
    • Cryptographic Number Theory
    • String Manipulation
    • Binary Data
    • External Operations
    • See Also
      • Decrypt
      • EncryptFile
      • EncryptedObject
      • SymmetricKey
      • GenerateSymmetricKey
      • GenerateAsymmetricKeyPair
      • GenerateDigitalSignature
      • Hash
      • FieldMasked
      • CellularAutomaton
      • ShiftRegisterSequence
      • BinarySerialize
      • AuthenticationDialog
    • Related Guides
      • Cryptography
      • Systems-Related String Operations
      • Discrete Mathematics
      • Cryptographic Number Theory
      • String Manipulation
      • Binary Data
      • External Operations

Encrypt["password",expr]

encrypts expr using the specified password, to give an encrypted object.

Encrypt[keyspec,expr]

encrypts expr using the cryptographic key specification keyspec.

Encrypt[expr]

interactively requests a password with which to encrypt expr.

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Options  
Method  
Applications  
Properties & Relations  
Possible Issues  
Timing  
Encrypted Data Size  
Incompatible Keys  
Incompatible Padding Modes  
Incompatible Block Modes  
See Also
Related Guides
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • Decrypt
    • EncryptFile
    • EncryptedObject
    • SymmetricKey
    • GenerateSymmetricKey
    • GenerateAsymmetricKeyPair
    • GenerateDigitalSignature
    • Hash
    • FieldMasked
    • CellularAutomaton
    • ShiftRegisterSequence
    • BinarySerialize
    • AuthenticationDialog
  • Related Guides
    • Cryptography
    • Systems-Related String Operations
    • Discrete Mathematics
    • Cryptographic Number Theory
    • String Manipulation
    • Binary Data
    • External Operations
    • See Also
      • Decrypt
      • EncryptFile
      • EncryptedObject
      • SymmetricKey
      • GenerateSymmetricKey
      • GenerateAsymmetricKeyPair
      • GenerateDigitalSignature
      • Hash
      • FieldMasked
      • CellularAutomaton
      • ShiftRegisterSequence
      • BinarySerialize
      • AuthenticationDialog
    • Related Guides
      • Cryptography
      • Systems-Related String Operations
      • Discrete Mathematics
      • Cryptographic Number Theory
      • String Manipulation
      • Binary Data
      • External Operations

Encrypt

Encrypt["password",expr]

encrypts expr using the specified password, to give an encrypted object.

Encrypt[keyspec,expr]

encrypts expr using the cryptographic key specification keyspec.

Encrypt[expr]

interactively requests a password with which to encrypt expr.

Details and Options

  • Encrypt yields EncryptedObject[…], suitable for decryption with Decrypt.
  • Encrypt[key,"string"] yields an EncryptedObject containing the encrypted version of the contents of the string as encoded in UTF-8.
  • Encrypt[key,ByteArray[…]] yields an EncryptedObject containing the encrypted version of the raw bytes in the ByteArray object.
  • For a general expression, Encrypt[key,expr] yields an EncryptedObject essentially containing an encrypted version of Compress[expr].
  • The encryption method is based on the cipher and parameters of the key. See GenerateSymmetricKey and GenerateAsymmetricKeyPair for details.
  • In a notebook interface, Encrypt[expr] generates a dialog box; in a textual interface it generates a textual prompt.
  • Encrypt has the following option:
  • Method Automaticdetails of encryption method
  • With the setting Methodassoc, the association assoc gives details of the encryption method to use.
  • The following elements can be given in the association assoc:
  • "Padding"Automaticpadding mode
    "InitializationVector"Automaticinitialization vector for block ciphers
    "BlockMode""CBC"block chaining mode ("ECB","CBC", "OFB", "CFB", "CTR")
  • The "Padding" element in the association assoc specifies the padding method to pad incomplete input.
  • Encryption with symmetric key supports the following padding methods: Automatic and None.
  • Encryption with a public key and decryption with a private key support the following padding methods: "PKCS1", "OAEP", None.
  • Encryption with a private key and decryption with a public key support the following padding methods: "PKCS1", None.
  • The "PKCS1" padding method is used as a default for asymmetric encryption.
  • All ciphers except RC4 and RSA can use the block modes "ECB", "CBC", "CFB", "OFB". "RC4" can only use None.
  • Possible settings for "InitializationVector" include:
  • Automaticgenerate an appropriate initialization vector
    ByteArray[…]use an explicitly specified initialization vector
  • With "InitializationVector"->Automatic, Encrypt will generate a new initialization vector whenever it is run. Later, the vector can be obtained from the EncryptedObject that was produced.
  • Supported ciphers, together with default initialization vector size, include:
  • "Blowfish"64 bits
    "CAST5"64 bits
    "DES"64 bits
    "IDEA"64 bits
    "AES128"128 bits
    "AES192"128 bits
    "AES256"128 bits
  • For RSA cipher, the maximum length of data that can be encrypted is determined by the number of bytes in the modulus, and the padding mode, according to:
  • "PKCS1"<
    "OAEP"<
    None

Examples

open all close all

Basic Examples  (3)

Encrypt a message with a password:

Show the raw encrypted data and details about the encryption algorithm used:

Decrypt with the password to get back the message:

Generate a secret key:

Encrypt using the key:

Generate public and private keys:

Encrypt using the public key:

Decrypt using the private key:

Alternatively, encrypt using the private key:

Now decrypt using the public key:

Scope  (2)

Encrypt any expression:

Byte arrays are encrypted literally, making them more easily usable with external programs:

Options  (5)

Method  (5)

Encrypt using a specific initialization vector:

With the initialization vector set to Automatic, a random initialization vector will be generated every time Encrypt is called:

Encrypt using CTR block mode:

Specify a padding scheme to use for RSA encryption:

Encrypt exactly one block of data by setting "Padding" to None:

Applications  (2)

Encrypt a message and save the ciphertext to a file:

Read back the contents of the file as bytes:

Compare with the original ciphertext:

Delete the temporary file:

Write simple cryptographic signing and verification functions:

Generate a pair of public and private keys:

Define an expression to sign:

Generate a signature:

Verify that the signature is authentic:

Verifying with another expression will fail:

Properties & Relations  (2)

The returned encrypted object stores all aspects of the encrypted result:

Extract the bytes in the ciphertext:

Extract the bytes in the initialization vector used for encryption:

Some block modes are more secure than others:

There is a noticeable repeating pattern when encrypting uniform data using ECB:

There is not with CBC:

Possible Issues  (5)

Timing  (1)

Encrypting using a password requires key derivation, which is intentionally slow:

You can avoid this by pre-generating a key:

Encrypted Data Size  (1)

The ciphertext may be a different length from the input:

Incompatible Keys  (1)

Encryption with elliptic curve-based keys is not currently supported:

Incompatible Padding Modes  (1)

Encrypting with a private key is not possible for certain padding modes:

Incompatible Block Modes  (1)

RSA is an asymmetric cipher that does not support block modes of operation, so Encrypt will proceed ignoring the setting for "BlockMode":

RC4 is a stream that does not support block modes of operation, so Encrypt will proceed ignoring the setting for "BlockMode":

See Also

Decrypt  EncryptFile  EncryptedObject  SymmetricKey  GenerateSymmetricKey  GenerateAsymmetricKeyPair  GenerateDigitalSignature  Hash  FieldMasked  CellularAutomaton  ShiftRegisterSequence  BinarySerialize  AuthenticationDialog

Related Guides

    ▪
  • Cryptography
  • ▪
  • Systems-Related String Operations
  • ▪
  • Discrete Mathematics
  • ▪
  • Cryptographic Number Theory
  • ▪
  • String Manipulation
  • ▪
  • Binary Data
  • ▪
  • External Operations

History

Introduced in 2015 (10.1) | Updated in 2019 (12.0) ▪ 2020 (12.1) ▪ 2021 (12.3) ▪ 2023 (13.3)

Wolfram Research (2015), Encrypt, Wolfram Language function, https://reference.wolfram.com/language/ref/Encrypt.html (updated 2023).

Text

Wolfram Research (2015), Encrypt, Wolfram Language function, https://reference.wolfram.com/language/ref/Encrypt.html (updated 2023).

CMS

Wolfram Language. 2015. "Encrypt." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2023. https://reference.wolfram.com/language/ref/Encrypt.html.

APA

Wolfram Language. (2015). Encrypt. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Encrypt.html

BibTeX

@misc{reference.wolfram_2025_encrypt, author="Wolfram Research", title="{Encrypt}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/Encrypt.html}", note=[Accessed: 01-December-2025]}

BibLaTeX

@online{reference.wolfram_2025_encrypt, organization={Wolfram Research}, title={Encrypt}, year={2023}, url={https://reference.wolfram.com/language/ref/Encrypt.html}, note=[Accessed: 01-December-2025]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • Notebook Assistant + LLM Kit
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Player
  • Wolfram Engine

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2025 Wolfram
© 2025 Wolfram | Legal & Privacy Policy |
English