栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

将C#RSACryptoServiceProvider转换为JAVA代码

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

将C#RSACryptoServiceProvider转换为JAVA代码

找到了解决方案。

String modulusString = "hm2oRCtP6usJKYpq7o1K20uUuL11j5xRrbV4FCQhn/JeXLT21laKK9901P69YUS3bLo64x8G1PkCfRtjbbZCIaa1Ci/BCQX8nF2kZVfrPyzcmeAkq4wsDthuZ+jPInknzUI3TQPAzdj6gim97E731i6WP0MHFqW6ODeQ6Dsp8pc=";String publicExponentString = "AQAB";byte[] modulusBytes = base64.deprebase64(modulusString);byte[] exponentBytes = base64.deprebase64(publicExponentString);BigInteger modulus = new BigInteger(1, modulusBytes);BigInteger publicExponent = new BigInteger(1, exponentBytes);RSAPublicKeySpec rsaPubKey = new RSAPublicKeySpec(modulus, publicExponent);KeyFactory fact = KeyFactory.getInstance("RSA");PublicKey pubKey = fact.generatePublic(rsaPubKey);Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1PADDING");cipher.init(Cipher.ENCRYPT_MODE, pubKey);byte[] plainBytes = clearTextPassword.getBytes("UTF-16LE");byte[] cipherData = cipher.doFinal(plainBytes);String encryptedStringbase64 = base64.enprebase64String(cipherData);


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/496135.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号