The cipher 'aes256-cbc' is required, but it is not available

When using jsch to connect SSH, encountered this:The cipher 'aes256-cbc' is required, but it is not available.

Environment: JDK 6

Solution: 

step 1: Download jce_policy-6.zip here: http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html

step 2: In the /JCE folder, you’ll get two JAR files – local_policy.jar and US_export_policy.jar Copy these two JAR files to the your JDK’s /jre/lib/security/ folder, replacing the similarly named files that are already there.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Java中,可以使用javax.crypto包中的类来进行AES256-CBC解密。下面是一个示例代码: ```java import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import java.util.Base64; public class AES256CBCDecryptor { public static String decrypt(String cipherText, String key, String iv) throws Exception { SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); IvParameterSpec ivParameterSpec = new IvParameterSpec(iv.getBytes("UTF-8")); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec); byte[] decryptedBytes = cipher.doFinal(Base64.getDecoder().decode(cipherText)); return new String(decryptedBytes); } public static void main(String[] args) throws Exception { String cipherText = "tX9IbG8QkZ0vJ/4G5Uq+2Q=="; String key = "01234567890123456789012345678901"; String iv = "0123456789012345"; String plainText = decrypt(cipherText, key, iv); System.out.println("Plain text: " + plainText); } } ``` 在代码中,我们首先定义了一个decrypt方法,该方法接受待解密的密文、密钥和初始化向量,并返回解密后的明文。该方法中,我们首先使用密钥和初始化向量创建SecretKeySpec和IvParameterSpec对象。然后,我们使用AES/CBC/PKCS5Padding算法创建一个Cipher对象,并使用init方法初始化为解密模式。最后,我们调用doFinal方法对密文进行解密,并将解密后的字节数组转换为字符串。 在main方法中,我们使用示例密文、密钥和初始化向量调用decrypt方法,并输出解密后的明文。请注意,示例代码中的密钥和初始化向量都是16字节长的字符串,因为AES256-CBC需要256位长密钥和128位长初始化向量。实际应用中,您应该使用更长的、随机生成的密钥和初始化向量来保证加密的安全性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值