하나의 문제가 있습니다. 내 응용 프로그램에서는 AES 암호화 및 암호 해독을 사용하고 있습니다. 데이터를 암호화하여 서버 측에 보내면 암호화 된 데이터에 일부 정크 문자가 추가 된 것으로 나타납니다. 그러나 어떻게?AES 암호화가 블랙 베리에 정크 문자를 추가했습니다.
실제로이 암호화 된 데이터는 내 측면에서 완벽하게 해독되지만 서버에서 수신하면 정크 문자가 있습니다. 내가 서버의 암호 해독 로직에 액세스 할 수없는
public static byte[] encrypt(byte[] keyData, byte[] data)
throws CryptoException, IOException
{
// Create the AES key to use for encrypting the data.
// This will create an AES key using as much of the keyData
// as possible.
AESKey key = new AESKey(keyData);
// Now, we want to encrypt the data.
// First, create the encryptor engine that we use for the actual
// encrypting of the data.
AESEncryptorEngine engine = new AESEncryptorEngine(key);
// Since we cannot guarantee that the data will be of an equal block
// length we want to use a padding engine (PKCS5 in this case).
PKCS5FormatterEngine fengine = new PKCS5FormatterEngine(engine);
// Create a BlockEncryptor to hide the engine details away.
ByteArrayOutputStream output = new ByteArrayOutputStream();
BlockEncryptor encryptor = new BlockEncryptor(fengine, output);
encryptor.write(data);
encryptor.close();
output.close();
return output.toByteArray();
}
참고 :
여기 내 암호화 코드입니다.
AES와 같은 블록 암호에는 패딩이 필요합니다.암호화 된 데이터가 원본보다 더 길다는 것은 절대적으로 정상입니다. 내 생각에 클라이언트 측에서 아무 것도 할 필요가 없다. –
서버 측 사람들은 분명히 암호화/해독을 처리하는 방법에 대한 단서를 가지고 있지 않습니다. 이 사실을 조직의 적절한 사람에게 알려줄 수 있습니다. 그들이하는 일은 완전히 안전하지 않습니다. –