Files
AutoJs6/app/src/main/assets/docs/crypto.html

214 lines
10 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>密文 (Crypto) | AutoJs6 文档 - 6.2.0</title>
<link rel="stylesheet" href="assets/fonts.css">
<link rel="stylesheet" href="assets/style.css">
<link rel="stylesheet" href="assets/sh.css">
<link rel="canonical" href="https://nodejs.org/api/crypto.html">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="user-scalable=no">
</head>
<body class="alt apidoc" id="api-section-crypto">
<div id="content" class="clearfix">
<div id="column2" class="interior">
<div id="intro" class="interior">
<a href="/" title="返回首页">
AutoJs6
</a>
</div>
<ul>
<li><a class="nav-overview" href="overview.html">Overview - 综述</a></li>
<li><a class="nav-documentation" href="documentation.html">About - 关于文档</a></li>
<li><a class="nav-progress" href="progress.html">Progress - 完善进度</a></li>
<li><a class="nav-changelog" href="changelog.html">Changelog - 更新日志</a></li>
<li><a class="nav-qa" href="qa.html">Q&amp;A - 疑难解答</a></li>
</ul>
<div class="line"></div>
<ul>
<li><a class="nav-https-developer-mozilla-org-zh-CN-docs-Web-JavaScript-" href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/">MDN - JavaScript 基础</a></li>
<li><a class="nav-https-zh-javascript-info-" href="https://zh.javascript.info/">JavaScript.info - JavaScript 教程</a></li>
</ul>
<div class="line"></div>
<ul>
<li><a class="nav-global" href="global.html">Global - 全局对象</a></li>
<li><a class="nav-automator" href="automator.html">Automator - 自动化</a></li>
<li><a class="nav-autojs" href="autojs.html">AutoJs6 - 本体应用</a></li>
<li><a class="nav-app" href="app.html">App - 通用应用</a></li>
<li><a class="nav-color" href="color.html">Color - 颜色</a></li>
<li><a class="nav-image" href="image.html">Image - 图像</a></li>
<li><a class="nav-keys" href="keys.html">Keys - 按键</a></li>
<li><a class="nav-device" href="device.html">Device - 设备</a></li>
<li><a class="nav-storages" href="storages.html">Storage - 储存</a></li>
<li><a class="nav-files" href="files.html">File - 文件</a></li>
<li><a class="nav-engines" href="engines.html">Engine - 引擎</a></li>
<li><a class="nav-tasks" href="tasks.html">Task - 任务</a></li>
<li><a class="nav-modules" href="modules.html">Module - 模块</a></li>
<li><a class="nav-plugins" href="plugins.html">Plugins - 插件</a></li>
<li><a class="nav-console" href="console.html">Console - 控制台</a></li>
<li><a class="nav-shell" href="shell.html">Shell</a></li>
<li><a class="nav-media" href="media.html">Media - 多媒体</a></li>
<li><a class="nav-sensors" href="sensors.html">Sensor - 传感器</a></li>
<li><a class="nav-recorder" href="recorder.html">Recorder - 记录器</a></li>
<li><a class="nav-timers" href="timers.html">Timer - 定时器</a></li>
<li><a class="nav-threads" href="threads.html">Thread - 线程</a></li>
<li><a class="nav-continuation" href="continuation.html">Continuation - 协程</a></li>
<li><a class="nav-events" href="events.html">Event - 事件监听</a></li>
<li><a class="nav-dialogs" href="dialogs.html">Dialog - 对话框</a></li>
<li><a class="nav-floaty" href="floaty.html">Floaty - 悬浮窗</a></li>
<li><a class="nav-canvas" href="canvas.html">Canvas - 画布</a></li>
<li><a class="nav-ui" href="ui.html">UI - 用户界面</a></li>
<li><a class="nav-web" href="web.html">Web - 万维网</a></li>
<li><a class="nav-http" href="http.html">HTTP</a></li>
<li><a class="nav-base64" href="base64.html">Base64</a></li>
<li><a class="nav-crypto active" href="crypto.html">Crypto - 密文</a></li>
<li><a class="nav-i18n" href="i18n.html">Internationalization - 国际化</a></li>
<li><a class="nav-e4x" href="e4x.html">E4X</a></li>
</ul>
<div class="line"></div>
<ul>
<li><a class="nav-glossaries" href="glossaries.html">Glossaries - 术语</a></li>
<li><a class="nav-exceptions" href="exceptions.html">Exceptions - 异常</a></li>
<li><a class="nav-intentType" href="intentType.html">Intent - 意图</a></li>
<li><a class="nav-runtime" href="runtime.html">Runtime - 运行时</a></li>
<li><a class="nav-context" href="context.html">Context - 上下文</a></li>
<li><a class="nav-activity" href="activity.html">Activity - 活动</a></li>
</ul>
<div class="line"></div>
<ul>
<li><a class="nav-dataTypes" href="dataTypes.html">Data Types - 数据类型</a></li>
<li><a class="nav-uiSelectorType" href="uiSelectorType.html">UiSelector - 选择器</a></li>
<li><a class="nav-uiObjectType" href="uiObjectType.html">UiObject - 控件节点</a></li>
<li><a class="nav-uiObjectCollectionType" href="uiObjectCollectionType.html">UiObjectCollection - 控件集合</a></li>
<li><a class="nav-uiObjectActionsType" href="uiObjectActionsType.html">UiObjectActions - 控件节点行为</a></li>
<li><a class="nav-appType" href="appType.html">App - 应用枚举类</a></li>
<li><a class="nav-versionType" href="versionType.html">Version - 版本工具类</a></li>
</ul>
<div class="line"></div>
<ul>
<li><a class="nav-polyfill" href="polyfill.html">Polyfill - 代码填泥</a></li>
<li><a class="nav-arrayx" href="arrayx.html">Arrayx - Array 扩展</a></li>
<li><a class="nav-numberx" href="numberx.html">Numberx - Number 扩展</a></li>
<li><a class="nav-mathx" href="mathx.html">Mathx - Math 扩展</a></li>
</ul>
<div class="line"></div>
<ul>
<li><a class="nav-scriptingJava" href="scriptingJava.html">Scripting Java - 脚本化 Java</a></li>
<li><a class="nav-apiLevel" href="apiLevel.html">Android API Level - 安卓 API 级别</a></li>
<li><a class="nav-colorTable" href="colorTable.html">Color Table - 颜色列表</a></li>
</ul>
<div class="line"></div>
<ul>
<li><a class="nav-https-github-com-SuperMonster003-AutoJs6-" href="https://github.com/SuperMonster003/AutoJs6/">GitHub - 应用项目地址</a></li>
<li><a class="nav-https-github-com-SuperMonster003-AutoJs6-Documentation" href="https://github.com/SuperMonster003/AutoJs6-Documentation">GitHub - 文档项目地址</a></li>
</ul>
</div>
<div id="column1" data-id="crypto" class="interior">
<header>
<h1>AutoJs6 文档 - 6.2.0</h1>
<div id="gtoc">
<p class="index">
<a href="index.html" name="toc">索引</a> |
<a href="all.html">查看全部</a>
</p>
</div>
<hr>
</header>
<div id="toc">
<h2>目录</h2>
<ul>
<li><span class="stability_undefined"><a href="#crypto_crypto">密文 (Crypto)</a></span><ul>
<li><span class="stability_undefined"><a href="#crypto_crypto_digest_message_algorithm_options">$crypto.digest(message, algorithm[, options])</a></span></li>
<li><span class="stability_undefined"><a href="#crypto_crypto_encrypt_data_key_algorithm_options">$crypto.encrypt(data, key, algorithm, options)</a></span></li>
<li><span class="stability_undefined"><a href="#crypto">输入和输出的类型和格式</a></span></li>
</ul>
</li>
</ul>
</div>
<div id="apicontent">
<h1>密文 (Crypto)<span><a class="mark" href="#crypto_crypto" id="crypto_crypto">#</a></span></h1>
<hr>
<p style="font: italic 1em sans-serif; color: #78909C">此章节待补充或完善...</p>
<p style="font: italic 1em sans-serif; color: #78909C">Marked by SuperMonster003 on Oct 22, 2022.</p>
<hr>
<p><strong> [<a href="https://pro.autojs.org/">Pro 8.0.0新增</a>] </strong></p>
<p>$crypto模块提供了对称加密(例如AES)、非对称加密(例如RSA)、消息摘要(例如MD5, SHA)等支持.</p>
<h2>$crypto.digest(message, algorithm[, options])<span><a class="mark" href="#crypto_crypto_digest_message_algorithm_options" id="crypto_crypto_digest_message_algorithm_options">#</a></span></h2>
<div class="signature"><ul>
<li><code>message</code> { <span class="type">any</span> }</li>
<li><code>algorithm</code> { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">string</a> } 消息摘要算法, 包括:<ul>
<li>MD5</li>
<li>SHA-1</li>
<li>SHA-256</li>
<li>SHA-384</li>
<li>SHA-512</li>
</ul>
</li>
<li><code>options</code> { <span class="type">any</span> }</li>
</ul>
</div><p>对信息message使用消息摘要算法<code>algorithm</code>进行摘要并返回结果, 默认的输出格式为hex.</p>
<p>参数message的类型默认为字符串, 返回值默认为hex可以通过options来指定参数message的类型和返回值的类型、格式, 比如文件、base64、字节数组、hex等. 参见《输入和输出的类型和格式》.</p>
<pre><code class="lang-javascript">// 计算字符串abc的md5
toastLog($crypto.digest(&quot;abc&quot;, &quot;MD5&quot;));
// 计算字符串abc的sha-256
toastLog($crypto.digest(&quot;abc&quot;, &quot;SHA-256&quot;));
// 计算文件/sdcard/1.txt的md5
toastLog($crypto.digest(&quot;/sdcard/1.txt&quot;, &quot;MD5&quot;, {
input: &quot;file&quot;
}));
</code></pre>
<h2>$crypto.encrypt(data, key, algorithm, options)<span><a class="mark" href="#crypto_crypto_encrypt_data_key_algorithm_options" id="crypto_crypto_encrypt_data_key_algorithm_options">#</a></span></h2>
<div class="signature"><ul>
<li><code>data</code> { <span class="type">any</span> } 明文消息</li>
<li><code>key</code> { <span class="type">Key</span> } 密钥</li>
<li><p><code>algorithm</code> { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">string</a> } 加密算法, 包括:</p>
<ul>
<li>AES</li>
<li>AES/ECB/NoPadding</li>
<li>AES/ECB/PKCS5Padding</li>
<li>AES/CBC/NoPadding</li>
<li>AES/CBC/PKCS5Padding</li>
<li>AES/CFB/NoPadding</li>
<li>AES/CFB/PKCS5Padding</li>
<li>AES/CTR/NoPadding</li>
<li>AES/CTR/PKCS5Padding</li>
<li>AES/OFB/PKCS5Padding</li>
<li>AES/OFB/PKCS5Padding</li>
<li>RSA/ECB/PKCS1Padding</li>
<li>RSA/ECB/NoPadding</li>
<li>...
具体可参阅 <a href="https://developer.android.com/reference/javax/crypto/Cipher/">javax.crypto.Cipher</a></li>
</ul>
</li>
<li><p><code>options</code> { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">Object</a> } 加密选项</p>
</li>
</ul>
</div><h2>输入和输出的类型和格式<span><a class="mark" href="#crypto" id="crypto">#</a></span></h2>
</div>
</div>
</div>
<script src="assets/sh_javascript.js"></script>
<script src="assets/sh_java.js"></script>
<script src="assets/sh_main.js"></script>
<script>
highlight(void 0, void 0, 'pre');
highlight(void 0, void 0, 'tt');
</script>
<!-- __TRACKING__ -->
</body>
</html>