String getString = new String(); String getString = new String();
inputParams.put("referenceid", referenceid);
inputParams.put("sourcetype",sourcetype );
inputParams.put("source", source);
byte[] encryptedJson=PasswordUtils.encryptJson(inputParams);
String encryptedInput=new String(encryptedJson);
public static byte[] encryptJson(JSONObject inputParams) throws Exception {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
ObjectOutputStream objectStream= new ObjectOutputStream(byteStream);
objectStream.writeObject(inputParams);
byte[] serializedObject=byteStream.toByteArray();
String key="qPNNbUwcSOhXgWGwdBOXopjgSNPynDkC";
byte[] keyByte=key.getBytes();
byte[] hashedKey=generateHash(keyByte);
SecretKeySpec secretKeySpec=new SecretKeySpec(hashedKey, "AES");
Cipher cipher=Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
byte[] encryptedObject=cipher.doFinal(serializedObject);
return encryptedObject;
}
字符串
我试图将整个json对象转换为加密数据,然后我应该为转换后的json数据提供输入,这里错误通过加密方法。这里我应该遵循AES ECB PCKS 5 Padding算法。
1条答案
按热度按时间dw1jzc5e1#
你想要这样东西吗??
字符串
我不确定我是否正确理解了你的问题