jpeg文件编码格式以0xFFD8起始,以0xFFD9结尾
BT种子嵌入到起始标志之前或者结尾标志之后均可以。
嵌入BT种子代码:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
char buf[10240];
int main()
{
char c;
cout << "image src file name (jpeg):";
cin >> buf;
ifstream fin(buf, ios_base::binary);
if (!fin.good()) {
cout << "can't open " << buf << endl;
}
fin.seekg(0, ios_base::end);
size_t size = fin.tellg();
fin.seekg(0, ios_base::beg);
cout << "image des file name (jpeg):";
cin >> buf;
ofstream fout(buf, ios_base::binary);
if (!fout.good()) {
cout << "can't open " << buf << endl;
}
cout << "BT link:";
cin >> buf;
fout.write(buf, strlen(buf));
c = 0;
fout.put(c);
for (size_t i = 0; i <size; i++)
{
c = fin.get();
fout.put(c);
}
fin.close();
fout.close();
}
提取BT种子代码:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
char buf[10240];
int main()
{
char c;
cout << "image file name (jpeg):";
cin >> buf;
ifstream fin(buf, ios_base::binary);
if (!fin.good()) {
cout << "can't open " << buf << endl;
}
fin.seekg(0, ios_base::end);
size_t size = fin.tellg();
fin.seekg(0, ios_base::beg);
size_t i = 0;
while (1)
{
c = fin.get();
buf[i++] = c;
if (c == 0)
break;
}
cout << buf << endl;
fin.close();
}