編輯:用提供的值替換示例值。
我不熟悉的RSA,但一般使用Dojo的RSAKey模塊的將是如下(根據其source code):
require([
\t "dojo/dom",
\t "dojox/encoding/crypto/RSAKey"
],function(dom, RSAKeyModule){
var RSAKey = new RSAKeyModule();
var n= "8efebfa74157b9447e1bc729d5e2a459ee888e87dc7ed764b473e513edba7696a957871ff7a4941ed360d1b42a9788bdc52a8b659357dc8f252e6cc5f5bbf5c659cc9e9837df4ca6eee1c47889b055ac3802bb9491e88483491b08dff9e9472d99341134bcfc4ecf38915553bda08f943089377a95c7118febcef2841288aedb1b8ba22e211da2ab527d26d7accf2e05421260a23f06cf2b13e0ffd51e8f401bc113768027ad29c371564d179c82639061272e4f940bf50ba6490933f788715f8c268dd2c85a461e899ba416a51557fec7a9a4f1ed3df95cf5bd14bb529dd331b9a79828366a9589deb32e730369cd62352ef7fdd9297e1193f4a33e01289a6f"
var e = "10001";
RSAKey.setPublic(n, e);
var encrypted = RSAKey.encrypt("abc");
dom.byId("result").innerHTML = encrypted;
});
<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
<div id="result"></div>
見dojo/request/xhr模塊 - 可能是有益的接收密鑰。
謝謝,我會試試看。 –
這是我的RSA公鑰: 模量:8efebfa74157b9447e1bc729d5e2a459ee888e87dc7ed764b473e513edba7696a957871ff7a4941ed360d1b42a9788bdc52a8b659357dc8f252e6cc5f5bbf5c659cc9e9837df4ca6eee1c47889b055ac3802bb9491e88483491b08dff9e9472d99341134bcfc4ecf38915553bda08f943089377a95c7118febcef2841288aedb1b8ba22e211da2ab527d26d7accf2e05421260a23f06cf2b13e0ffd51e8f401bc113768027ad29c371564d179c82639061272e4f940bf50ba6490933f788715f8c268dd2c85a461e899ba416a51557fec7a9a4f1ed3df95cf5bd14bb529dd331b9a79828366a9589deb32e730369cd62352ef7fdd9297e1193f4a33e01289a6f 公用指數:10001 –
在我的Java應用程序可以對消息進行加密就好,正確使用私鑰解密: –