CFB 모드에서 AES 인 것으로 암호화 된 부분이있는 기존 데이터 형식이 있습니다. 평문 데이터 길이와 암호화 된 데이터 길이는 동일합니다.C#에서 AES 암호화 (일반 텍스트 길이가 암호화 된 길이와 같음)
C#에서는 암호화 된 길이가 블록 크기의 배수가 될 것으로 기대하는 것처럼 보이기 때문에 데이터를 해독하려는 예외가 발생합니다.
솔루션을 연구 할 때 Crypto ++를 사용하여 데이터를 성공적으로 해독하는 빠른 C++ 앱을 작성하여 적절한 알고리즘, 키 및 IV를 사용하고 있음을 확신합니다. 이 잘 작동하지만 가능한 모든 경우 C# 안에 모든 것을 유지하고 싶습니다. 어떤 제안? 아래
작업 C++ 코드 :
//define key
unsigned char key[16];
//populate key
//...
//define iv
unsigned char iv[16];
//populate iv
//...
std::ifstream inFile;
//open file
inFile.open("file.aes",ios::binary);
//get file size
inFile.seekg(0,ios::end);
int fileSize = (int) inFile.tellg();
inFile.seekg(offset, ios::beg);
//read/close file
char* inBytes = new char[fileSize];
inFile.read(inBytes,fileSize);
inFile.close();
//configure decryption
CFB_Mode<AES>::Decryption cfbDecryption(key, 16, iv);
//populate output bytes
char* outBytes = new char[fileSize];
cfbDecryption.ProcessData((byte*) outBytes,(byte*) inBytes,fileSize);
//open/write/close output file
std::ofstream outFile;
outFile.open("out.dec");
outFile.write(outBytes,fileSize);
outFile.close();
delete[] inBytes;
당신은 당신이 시도 C# 코드 당신은 점점 예외를 게시 할 수 있습니까? – Xint0
[this] (http://stackoverflow.com/questions/3142279/encrypt-data-with-c-sharp-aescryptoserviceprovider-crypted-with-bouncycastle-aes) 질문에 대한 답변을 확인 했습니까? –
@GregS q & a는 약간의 사랑을 사용할 수 있습니다. 착각하지 않으면 기본적으로 구현됩니다. –