第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

解密時(shí)報(bào)如下異常: javax.crypto.IllegalBlockSizeException: Data must not be longer than 245 bytes

//1初始化秘鑰
			KeyPairGenerator?keyPairGenerator?=?KeyPairGenerator.getInstance("RSA");
			keyPairGenerator.initialize(2048);
			KeyPair?keyPair?=?keyPairGenerator.generateKeyPair();
			RSAPublicKey?rsaPublicKey?=?(RSAPublicKey)?keyPair.getPublic();
			RSAPrivateKey?rsaPrivateKey?=?(RSAPrivateKey)?keyPair.getPrivate();
			System.out.println("PublicKey:"+Base64.encodeBase64(rsaPublicKey.getEncoded()));
			System.out.println("PrivateKey:"+Base64.encodeBase64(rsaPrivateKey.getEncoded()));
			
			//2私鑰加密,公鑰解密——加密
			PKCS8EncodedKeySpec?pkcs8EncodedKeySpec?=?new?PKCS8EncodedKeySpec(rsaPrivateKey.getEncoded());
			KeyFactory?keyFactory?=?KeyFactory.getInstance("RSA");
			PrivateKey?privateKey?=?keyFactory.generatePrivate(pkcs8EncodedKeySpec);
			Cipher?cipher?=?Cipher.getInstance("RSA");
			cipher.init(Cipher.ENCRYPT_MODE,?privateKey);
			byte[]?result?=?cipher.doFinal(s.getBytes());//待加密的字符串
			System.out.println("加密密文:"+Base64.encodeBase64(result));
			
			//2私鑰加密,公鑰解密——解密
			X509EncodedKeySpec?x509EncodedKeySpec?=?new?X509EncodedKeySpec(rsaPublicKey.getEncoded());
			KeyFactory?keyFactory1?=?KeyFactory.getInstance("RSA");
			PublicKey?publicKey?=?keyFactory1.generatePublic(x509EncodedKeySpec);
			Cipher?cipher1?=?Cipher.getInstance("RSA");
			cipher1.init(Cipher.DECRYPT_MODE,?publicKey);
			result?=?cipher.doFinal(result);
			System.out.println("解密密文:"+new?String(result));


正在回答

4 回答

這個(gè)是加密的字符串太長(zhǎng)了,我也沒(méi)找到解決方案的,誰(shuí)有辦法請(qǐng)明示

0 回復(fù) 有任何疑惑可以回復(fù)我~

什么鬼

0 回復(fù) 有任何疑惑可以回復(fù)我~

還是報(bào)相同的錯(cuò),只不過(guò)

Data must not be longer than 245 bytes

不是245了



0 回復(fù) 有任何疑惑可以回復(fù)我~

keyPairGenerator.initialize(2048); ?====>keyPairGenerator.initialize(512); 或

keyPairGenerator.initialize(1024);

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

解密時(shí)報(bào)如下異常: javax.crypto.IllegalBlockSizeException: Data must not be longer than 245 bytes

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)