#include #include #include #include #include #include using namespace std; string header(unsigned int content_size){ char head[32] = {0xAF, 0x90, 0x88, 0x9A, 0x8D, 0xAA, 0xAC, 0xBD,0x31, 0x00, 0x10, 0x00, 0x10, 0x00, (content_size& 1) + 0x41, 0x01, content_size >>24, content_size >>16 , content_size >>8, content_size , (content_size& 1) + 0xB8}; FILE* fichier = NULL; fichier = fopen("test.hexadecimal", "wb+"); for(int i = 0 ; i<32; i++) fputc(head[i], fichier); fclose(fichier); return head; } string intToString(int i) { string str; char x; int n=0; while((x = (i >> (8*n)) & 0xff) != 0){ n++; str.insert(0,1,x); } return str; } string replaceAll(std::string str, const std::string& from, const std::string& to) { if(from.empty()) return str; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } return str; } bool build(vector input, vector output, map dictionary){ map inputContent; for(int i=0; i outputContent; for(map::iterator it = dictionary.begin(); it != dictionary.end(); ++it){ for(map::iterator ite = inputContent.begin(); ite != inputContent.end(); ++ite){ replaceAll(ite->second,it->first, intToString(it->second) ); } } }