在 Google Apps Script 中使用 Crypto-JS - 什么是 C.lib? [英] Using Crypto-JS in Google Apps Script - What is C.lib?

查看:34
本文介绍了在 Google Apps Script 中使用 Crypto-JS - 什么是 C.lib?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我们在 Google Apps Script 中使用 Crypto-JS 并将所有源文件复制到我的项目中.

I would like to us Crypto-JS in Google Apps Script and have copied all source files into my project.

尝试使用 AES 加密数据时,我无法使其正常工作,因为 aes.js 中的以下引用在 Google Apps 脚本中无效:

When trying to encrypt data with its AES, I can't get it to work because the following reference in aes.js is not valid in Google Apps Script:

var C_lib = C.lib;

这是我的JavaScript for Dummies"问题(我是 JavaScript 新手):-)

This is my "JavaScript for Dummies" question (I am a JavaScript newbie) :-)

如何在 Google Apps 脚本中引用和使用 C.lib?什么是C.lib?我没有在 Google 和 SO 上找到任何好的信息.

How can I reference and use C.lib with Google Apps Script? What is C.lib? I have not found any good information on Google and SO.

推荐答案

来自 core.js:

/**
 * Library namespace.
 */
var C_lib = C.lib = {};

似乎 CryptoJS 包中的每个文件都使用它,例如:

It seems that every file from the package CryptoJS use it something like:

var C_lib = C.lib;
var WordArray = C_lib.WordArray;
var BlockCipher = C_lib.BlockCipher;

因此,如果您使用的是开发版本,很可能您必须链接 core.js.

So, most probably you have to link core.js if you are using development version.

来自 CryptoJS 3.1

<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script>
<script>
    var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase");

    var decrypted = CryptoJS.AES.decrypt(encrypted, "Secret Passphrase");
</script>

无需任何其他链接即可工作.

works without any other links.

这篇关于在 Google Apps Script 中使用 Crypto-JS - 什么是 C.lib?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆