简体   繁体   English

可以将Nodejs模块下载为javascript文件吗?

[英]can I download Nodejs modules as javascript files?

I'd like to use the crypto module from nodejs but I don't want to use the entire framework. 我想使用来自nodejs的加密模块 ,但我不想使用整个框架。

Is where any way to simply download the js files for a particular library that I would normally require if I were working in node. 就是任何方式直接下载js文件的,我通常会在特定的库require ,如果我在节点进行工作。 If I had the Javascript file I could just include it with my project, and that's good enough for this one. 如果我有Javascript文件,则可以将其包含在我的项目中,这对于这个文件已经足够了。

When in doubt, always check github. 如有疑问,请始终检查github。 Source code is found in the component folder: https://github.com/sytelus/CryptoJS 在组件文件夹中找到源代码: https : //github.com/sytelus/CryptoJS

On a side note: I'd highly recommend using npm in general practice. 附带说明:我强烈建议在一般实践中使用npm。 Along with dependency fixes/testing/etc it makes it really simple to manage projects and keep them up to date. 除依赖修复/测试/等等外,它还使管理项目并使之保持最新状态变得非常简单。

Perhaps the Stanford Javascript Crypto Library could be a useful "node.js free" alternative for you. 斯坦福Javascript加密库可能是对您有用的“ node.js free”替代方案。 Here's a direct link to the minified source you could drop in to start playing with the API. 这是直接链接到您可以开始使用API​​的压缩源的直接链接。 While basic, observe the following proof of concept... 虽然基本,但请注意以下概念证明...

let pw = sjcl.random.randomWords(256 / 32);
let ct = sjcl.encrypt(pw, 'sooperstrong!');
let pt = sjcl.decrypt(pw, ct);

console.log(pt); // sooperstrong!

JSFiddle Link - demo JSFiddle Link-演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM