本文目录一览:
javascript怎样利用C#生成的RSA公钥对字符串加密?
js对公钥串进行加密的写法:
依赖:RSA.js BigInt.js 和Barrett.js
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
html:html lang="true"
head
html:base /
titlelogin/title
meta http-equiv="pragma" content="no-cache"
script type="text/javascript" src="js/RSA.js"/script
script type="text/javascript" src="js/BigInt.js"/script
script type="text/javascript" src="js/Barrett.js"/script
script type="text/javascript"
function rsalogin()
{
bodyRSA();
var result = encryptedString(key, document.getElementById("pwd").value);
//alert(result);
loginForm.action="login.do?result="+result;
loginForm.submit();
}
var key ;
function bodyRSA()
{
setMaxDigits(130);
key = new RSAKeyPair("10001","","8c1cd09a04ed01aafe70dc84c5f32ae23a16fe8fc8898aba6797c5a9c708720de4f08dbf086af429fc51c0636208f56de20a8ab5686affd9bdfb643ae1e90d5617155c4867eef06b0884ba8ecd187907c7069ae3eed4f0155eeca6573411864035ae803ad8fd91a0cc479f27e41b19c13465ab30f3cfbfd14de56f49cbd09481");
}
/script
如何从一个nodejs子进程的CWD
1.启动子与父目录的CWD:
var exec = require('child_process').exec;
var path = require('path')
var parentDir = path.resolve(process.cwd(), '..');
exec('doSomethingThere', {cwd: parentDir}, function (error, stdout, stderr) {
// if you also want to change current process working directory:
process.chdir(parentDir);
});
更新:如果你想找回子的CWD:
var fs = require('fs');
var os = require('os');
var exec = require('child_process').exec;
function getCWD(pid, callback) {
switch (os.type()) {
case 'Linux':
fs.readlink('/proc/' + pid + '/cwd', callback); break;
case 'Darwin':
exec('lsof -a -d cwd -p ' + pid + ' | tail -1 | awk \'{print $9}\'', callback);
break;
default:
callback('unsupported OS');
}
}
// start your child process
// note that you can't do like this, as you launch shell process
// and shell's child don't change it's cwd:
// var child1 = exec('cd .. sleep 1 cd .. sleep 1');
var child1 = exec('some process that changes cwd using chdir syscall');
// watch it changing cwd:
var i = setInterval(getCWD.bind(null, child1.pid, console.log), 100);
child1.on('exit', clearInterval.bind(null, i));
2.
如果你想获得当前的工作目录,而不诉诸操作系统行实用程序,你的“作战测试”shelljs库,这些抽象的东西给你,而子进程。
var sh = require("shelljs");
var cwd = sh.pwd();
有你有它的变量CWD握着你的当前工作目录,无论你在Linux,Windows CodeGo.net,或FreeBSD。
3.
只是一个想法,如果你知道子进程的PID,并pwdx安装(有可能在Linux上),你可以从一个节点得到子的CWD执行。