예제 #1
0
void
caesar_cipher::encryption(  const std::string &key,
                            const std::string &in,
                            const std::string &out )
{
    std::ifstream f_in(in, std::ifstream::in);
    std::ofstream f_out;

    if (out == "") {
        std::string out_file = std::string(ENC_PREF) + in;
        f_out.open(out_file, std::ifstream::out);
    } else
        f_out.open(out, std::ofstream::out);

    int keyPos = 0;
    char keyByte = 0;
    char dataByte = 0;

    while (f_in.get(dataByte)) {
        keyByte = key[keyPos];
        dataByte = EncryptByte(dataByte, keyByte);
        f_out << dataByte;
        keyPos = (++keyPos) % key.length();
    }

    f_in.close();
    f_out.close();
}
예제 #2
0
void CCipher::EncryptHeader(Byte *buf)
{
  for (unsigned i = 0; i < kHeaderSize; i++)
    buf[i] = EncryptByte(buf[i]);
}
예제 #3
0
파일: ZipCrypto.cpp 프로젝트: bks/qz7
void CCipher::EncryptHeader(Byte *buffer)
{
  for (int i = 0; i < 12; i++)
    buffer[i] = EncryptByte(buffer[i]);
}