python和java中相同的 AES/CFB/NoPadding加密

python和java的AES/CFB/NoPadding加密还是有点区别的
实现相同的加密方式
上代码
python中

def encrypt_(text):
    key = 'keyxxx'.encode()
    mode = AES.MODE_CFB
    cryptos = AES.new(key, mode, 'ivxxxx'.encode(),segment_size=128)
    cipher_text = cryptos.encrypt(text.encode())
    return base64.b64encode(cipher_text).decode()

java中(自己base64编一下码就行)

public static byte[] aes_cfb_nopadding(String paramString2)
	  {
    
    
	      Cipher localCipher = Cipher.getInstance("AES/CFB/NoPadding");
	      localCipher.init(1, new SecretKeySpec("keyxxx".getBytes("UTF-8"), "AES"), new IvParameterSpec("ivxxxx".getBytes("UTF-8"));
	      return localCipher.doFinal(paramString2.getBytes("UTF-8"))
	  }

需要解决问题的话,进群
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/m0_38124502/article/details/113050171
今日推荐