[英]How to decode base64 file path string in to apple script?
我正在写一个苹果脚本,它将base64字符串作为参数。 base64参数是文件路径。 我必须在特定的应用程序中打开此文件。 我需要解码此输入参数以打开文件。
我尝试了以下代码,但路径分隔符(/)被解码为%2F 。
set decodedFilePath to base64decode(filePath)
on base64decode(str)
return do shell script "openssl enc -base64 -d <<END_OF_TEXT" & str & "END_OF_TEXT"
end base64decode
我如何将base64文件路径字符串解码为AppleScript,这也将解码文件分隔符?
除非您特别需要使用openssl
否则为什么不只使用base64
呢?
下面的示例 的AppleScript 代码解密一个base64
用于例如经编码的文件路径名/Temp/base64.pdf
,为手动页面的PDF文档base64
。
set filePath to "L1RlbXAvYmFzZTY0LnBkZgo="
set decodedFilePath to base64decode(filePath)
on base64decode(str)
return do shell script "base64 -D <<<" & quoted form of str
end base64decode
这也适用于:
return do shell script "openssl enc -base64 -d <<<" & quoted form of str
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.