#include #include #include #include #include #include "SecureBuffer.h" using namespace std; int main(int argc, char * argv[]) { try{ fstream passwd("passwd", ios::in | ios::out); if(!passwd)//file can not be opened { cerr << "File 'passwd' couldn't be opened\n"; abort(); } /* format of "passwd" The file is a series of zero or more records that are all the same size. The file starts with zero or more user records. Each user record contains one Buffer(name or id) and one SecureBuffer(password): 0: name:Buffer, encrypted_password:SecureBuffer 1: name:Buffer, encrypted_password:SecureBuffer 2: name:Buffer, encrypted_password:SecureBuffer ... At the end of the file there may be zero of more deleted records, each deleted record has two blank buffers. */ const int record_size= sizeof(Buffer)+sizeof(SecureBuffer); int number_of_recs; passwd.seekp(0, ios::end); number_of_recs=passwd.tellp()/record_size ; cout << "Number of records = " << number_of_recs << endl; Buffer id; Buffer blank; for(int record_number=0; record_number