Reading from file to bitset

Hi, I have an enciphering function:
encipher(long data[2], long key[4])
This function is called when I want to change data (2*32bits) from the file to enciphered data using the key (128 bits).
The problem is that I don't know how to read binary from a file and call the function?
How would you do it?
I thought I could use bitset, but it can't take binary from string.

Hope you can help me!
This demontrates the syntax.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <fstream>

int main()
{
    long data[2] = { 1234, 5678 };

    // syntax for writing an array
    {
        std::ofstream os("data.dat", std::ios::binary);
        os.write(reinterpret_cast<char*>(&data), sizeof(data)); // read long array
    }

    // syntax for reading an array
    {
        std::ifstream is("data.dat", std::ios::binary);
        is.read(reinterpret_cast<char*>(&data), sizeof(data)); // read long array
    }

    return 0;
}
Topic archived. No new replies allowed.