前のBinaryクラスで簡単なサンプルを作成。PNGファイルを暗号->複合。
非常にあっさりとしたプログラムになる。

int _tmain(int argc, _TCHAR* argv[])
{
_tsetlocale ( LC_ALL, L"" );
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF|_CRTDBG_LEAK_CHECK_DF);

// AES256でPNGファイルを暗号化
{
Binary png, dst;
BinaryRead( L"E:\\work\\sample.PNG", png );

std::wstring pwd = L"東京都特許許可局"; // パスワード:実在しない団体

Binary bipwd = utf8(pwd); // 漢字が含まれるのでutf8
Binary pwd2 = hash(bipwd,2); // sha256化(32byte)

std::wstring temp = base64(pwd2);
std::wcout << L"pasword is '" << temp << L"'\n"; // 表示してみる

aes256( true, pwd2, png, dst ); // 暗号化 png->dst

BinaryWrite( L"E:\\work\\enc.bin", dst ); // 書き込み
}

// 暗号化されたファイルを複合化
{
std::wstring pwd = L"東京都特許許可局";

Binary png, dst;
BinaryRead( L"E:\\work\\enc.bin", dst );

Binary bipwd = utf8(pwd);
bipwd = hash(bipwd,2);

aes256( false, bipwd, dst, png ); // 複合化 dst->png

BinaryWrite( L"E:\\work\\sample2.PNG", png ); // 書き込み
}


{
Binary png1, png2;
BinaryRead( L"E:\\work\\sample.PNG", png1 ); // 元のファイル
BinaryRead( L"E:\\work\\sample2.PNG", png2 ); //変換されたファイル

std::wstring s1 = hex(hash(png1,2));
std::wstring s2 = hex(hash(png2,2));

_ASSERT( s1 == s2 ); // 同じならtrueになるはず

}

std::wcout << L"success";

return 0;
}