EncryptFile ["password",file]
generates an encrypted version of a file, using the specified password.
EncryptFile ["password",source,target]
generates an encrypted version of source, putting the result in target.
EncryptFile [keyspec,source,…]
encrypts using the cryptographic key specification keyspec.
EncryptFile
EncryptFile ["password",file]
generates an encrypted version of a file, using the specified password.
EncryptFile ["password",source,target]
generates an encrypted version of source, putting the result in target.
EncryptFile [keyspec,source,…]
encrypts using the cryptographic key specification keyspec.
Details and Options
- EncryptFile generates an encrypted file, suitable for decryption with DecryptFile .
- EncryptFile works with both files and cloud objects.
- EncryptFile [key,file] returns the name of the encrypted version of file.
- EncryptFile [key,CloudObject […]] returns a new anonymous cloud object containing the encrypted version of the contents of the original cloud object.
- EncryptFile [key,File […]] is also supported.
- The cryptographic key specification keyspec for EncryptFile [keyspec,…] has the same form as for Encrypt .
- EncryptFile has the following options:
-
Method Automatic details of encryption method
- EncryptFile uses the same Method option specifications as Encrypt .
- The setting for Permissions affects only cloud objects newly created by EncryptFile [key,CloudObject […]], not cloud objects explicitly specified as targets.
- With Permissions->Automatic , any permissions set will be given by $Permissions .
- The setting for OverwriteTarget affects only files to be newly created by EncryptFile [key,file] whose names would collide with existing files.
Examples
open all close allBasic Examples (4)
Write a string to the file:
Encrypt the file using a password:
Delete the original file:
Decrypt the encrypted file:
Read the decrypted file:
Delete the files used in this example:
Encrypt a file containing an image, putting the result in a new file:
Decrypt the encrypted file, again putting the result in a new file:
Import the decrypted file:
Delete the files used in this example:
Create a cloud object:
Encrypt the cloud object, getting back another cloud object:
Decrypt the encrypted cloud object, getting back yet another cloud object:
Get the contents of the decrypted cloud object:
Create an archive file from a directory:
Encrypt the archive file:
Delete the original archive:
Decrypt the encrypted archive:
Extract the archive into the current directory:
Delete the extracted directory and intermediate files used in this example:
Scope (2)
Encrypt a file and put the result in a cloud object:
Decrypt the cloud object and put the result into a local file:
Import the file:
Generate a key:
Encrypt using the key:
Decrypt using the same key:
Options (2)
Permissions (1)
Create a cloud object:
Encrypt the cloud object, setting the permissions of the resulting cloud object to public:
The encrypted cloud object is now publicly readable:
OverwriteTarget (1)
Write a string to the file tmp.txt:
Close the file:
Encrypt the file, getting back the tmp.txt.mx:
This attempts to write over tmp.txt.mx:
With OverwriteTarget->True , EncryptFile overwrites tmp.txt.mx:
Properties & Relations (2)
Write a string to the file tmp.txt:
Encrypt the file tmp.txt using a password:
Importing the file written by EncryptFile gives an EncryptedObject :
Clean up the files used:
Write a string to the file tmp.txt:
Encrypt the file:
The original and encrypted files are about the same size:
Clean up the files used:
Related Guides
Text
Wolfram Research (2017), EncryptFile, Wolfram Language function, https://reference.wolfram.com/language/ref/EncryptFile.html (updated 2020).
CMS
Wolfram Language. 2017. "EncryptFile." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/EncryptFile.html.
APA
Wolfram Language. (2017). EncryptFile. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/EncryptFile.html
BibTeX
@misc{reference.wolfram_2025_encryptfile, author="Wolfram Research", title="{EncryptFile}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/EncryptFile.html}", note=[Accessed: 06-December-2025]}
BibLaTeX
@online{reference.wolfram_2025_encryptfile, organization={Wolfram Research}, title={EncryptFile}, year={2020}, url={https://reference.wolfram.com/language/ref/EncryptFile.html}, note=[Accessed: 06-December-2025]}