加密javascript中的字符串和java中的解密

我想知道是否有人知道任何库在javascript和java解密加密。 我已经尝试了很多API,但是在java中获得的不是相同的值。
我想要公钥 – 私钥加密,因此尝试使用RSA。 我很少使用的是:

  1. http://www-cs-students.stanford.edu/~tjw/jsbn/
  2. http://ats.oka.nu/titaniumcore/js/crypto/readme.txt
  3. http://www.ohdave.com/rsa/

我检查的东西很少,javascript将字符串分成小块然后加密它们,这使得密码文本在java和javascript中不同。 我编辑javascript代码使用字符串作为一个整体但没有工作。

我也尝试将html页面的charset设置为utf-8,但它也没有用。 我成功加密像’K’这样的单字符串正确加密和解​​密,这让我觉得加密javascript中的字符串是有问题的,把它分成小块(我检查过,但它失败了加密它作为一个整个)。

我的java实现是:

BigInteger d = new BigInteger("1f3fac65c4ae222e3a3074dd4c38fbb72c0705c4bbac0385b867c12c25a44e01", 16); BigInteger e = new BigInteger("65537"); BigInteger N = new BigInteger("b42e91fbca364cf2a125aec67ffbdab624fd401100c40ea05189ba34d1028b0d", 16); String messageToEncrypt = "kishor"; byte [] messageByte = messageToEncrypt.getBytes(); BigInteger message = new BigInteger(messageByte); //Encrypting and Decrypting messages //Encrypt a message using N and e: BigInteger ciphertext = message.modPow(e, N); //Decrypt the message using N and d: BigInteger plaintext = ciphertext.modPow(d, N); byte[] plainTextByte = plaintext.toByteArray(); String decryptMessage = new String(plainTextByte); /*System.out.println("p : " + p); System.out.println("q : " + q);*/ System.out.println("N : " + N.toString(16)); System.out.println("e : " + e.toString(16)); System.out.println("d : " + d.toString(16)); /*System.out.println("PhiN : " + PhiN);*/ System.out.println("ciphertext : " + ciphertext.toString(16)); System.out.println("decryptMessage : " + decryptMessage); } 

请告诉我是否可能,因为我搜索了很多问题(在stackoverflow本身)但无法找到解决方案。

试试Gibberish AES(JS Lib) https://github.com/mdp/gibberish-aes/

RSA最适合密钥交换。 根据我的经验,那些使用它的人不知道他们在做什么,如果他们坚持下去,最终会建立一个毫无价值的加密系统。

我已经成功地在Java和Stanford Javascript Crypto Library之间进行了互操作。 还有许多其他用于对称加密算法的优秀JavaScript库。

嘿家伙我找到了解决方案。 在javascript中,第一个角色被加密导致问题。 修复了循环。 感谢你的回复。