DecryptFile["password",file]
用指定的密码产生文件的解密版本.
DecryptFile["password",source,target]
产生 source 的解密版本,并把结果放入 target.
DecryptFile[keyspec,source,…]
用加密密钥指定 keyspec 进行解密.
DecryptFile
DecryptFile["password",file]
用指定的密码产生文件的解密版本.
DecryptFile["password",source,target]
产生 source 的解密版本,并把结果放入 target.
DecryptFile[keyspec,source,…]
用加密密钥指定 keyspec 进行解密.
更多信息和选项
- DecryptFile 接受被 EncryptFile 加密的文件.
- DecryptFile 适用于文件和云对象.
- DecryptFile[key,file] 返回 file 的解密版本的名称,如果无法利用 key 对文件进行解密,则返回 $Failed.
- DecryptFile[key,CloudObject[…]] 返回一个新的匿名云对象,其中含有原来云对象的内容的解密版本,如果无法利用 key 对原来的云对象进行解密,则返回 $Failed.
- 同时还支持 DecryptFile[key,File[…]].
- DecryptFile[keyspec,…] 的加密密钥指定 keyspec 与 Decrypt 的加密密钥指定形式相同.
- DecryptFile 有下列选项:
-
Permissions Automatic 为已创建的云对象设置的权限 OverwriteTarget False 是否用自动命名的新文件覆盖现有文件 - Permissions 的设置只影响 DecryptFile[key,CloudObject[…]] 新创建的云对象,不影响明确指定作为目标的云对象.
- 当设置为 Permissions->Automatic 时,由 $Permissions 给出权限设置. 然而,如果 $Permissions 不是 "Private",DecryptFile 将会在产生云对象时给出一条消息.
- OverwriteTarget 的设置只影响由 DecryptFile[key,file] 新创建的、名称与现有文件冲突的文件.
范例
打开所有单元 关闭所有单元基本范例 (4)
WriteString["tmp.txt", "Now is the time..."]Close["tmp.txt"]EncryptFile["my password", "tmp.txt"]DeleteFile["tmp.txt"]DecryptFile["my password", "tmp.txt.mx"]ReadString["tmp.txt"]DeleteFile[{"tmp.txt", "tmp.txt.mx"}]EncryptFile["my password", FindFile["ExampleData/rose.gif"], "codedrose.mx"]DecryptFile["my password", "codedrose.mx", "rose.gif"]Import["rose.gif"]DeleteFile[{"codedrose.mx", "rose.gif"}]CloudPut["Now is the time..."]EncryptFile["my password", %]DecryptFile["my password", %]CloudGet[%]CreateArchive[$InstallationDirectory <> "/Documentation/English/System/ExampleData/", "example.zip"]EncryptFile["my password", %]DeleteFile["example.zip"]DecryptFile["my password", "example.zip.mx"]ExtractArchive["example.zip"];DeleteDirectory["ExampleData", DeleteContents -> True]DeleteFile[{"example.zip", "example.zip.mx"}]范围 (2)
EncryptFile["my password", FindFile["ExampleData/rose.gif"], CloudObject[]]DecryptFile["my password", %, "newrose.gif"]Import[%]DeleteFile["newrose.gif"]key = GenerateSymmetricKey[]EncryptFile[key, FindFile["ExampleData/rose.gif"], "rose.gif.mx"]DecryptFile[key, %]DeleteFile[{"rose.gif", "rose.gif.mx"}]选项 (2)
Permissions (1)
OverwriteTarget (1)
WriteString["tmp.txt", "Now is the time..."]EncryptFile["my password", "tmp.txt"]DecryptFile["my password", "tmp.txt.mx"]设置 OverwriteTarget->True,现在 DecryptFile 可以覆盖 tmp.txt:
DecryptFile["my password", "tmp.txt.mx", OverwriteTarget -> True]DeleteFile[{"tmp.txt", "tmp.txt.mx"}]可能存在的问题 (2)
WriteString["tmp.txt", "Now is the time..."]Close["tmp.txt"]EncryptFile["my password", "tmp.txt"]DeleteFile["tmp.txt"]DecryptFile["not my password", "tmp.txt.mx"]DeleteFile["tmp.txt.mx"]CloudPut["Now is the time..."]EncryptFile["my password", %]如果 $Permissions 不是 "Private",DecryptFile 会给出出错消息:
Block[{$Permissions = "Public"}, DecryptFile["my password", %]]如果明确设置 Permissions 选项,则不会发出出错消息:
Block[{$Permissions = "Public"}, DecryptFile["my password", %%, Permissions -> "Public"]]文本
Wolfram Research (2017),DecryptFile,Wolfram 语言函数,https://reference.wolfram.com/language/ref/DecryptFile.html (更新于 2020 年).
CMS
Wolfram 语言. 2017. "DecryptFile." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2020. https://reference.wolfram.com/language/ref/DecryptFile.html.
APA
Wolfram 语言. (2017). DecryptFile. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/DecryptFile.html 年
BibTeX
@misc{reference.wolfram_2026_decryptfile, author="Wolfram Research", title="{DecryptFile}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/DecryptFile.html}", note=[Accessed: 10-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_decryptfile, organization={Wolfram Research}, title={DecryptFile}, year={2020}, url={https://reference.wolfram.com/language/ref/DecryptFile.html}, note=[Accessed: 10-September-2026]}