Joey, You are going to have to excuse my ignorance of c++, but I am a bit confused as far as the ppdbuffersize and ppdbuffer. Is there additional code I would need to add elsewhere for these variables, and if so, would you mind including those as well??
I'm very sorry if this is really stupid, but I'm stuck in a C#.Net world and don't have to deal with this stuff. Thanks! Bob -----Original Message----- From: Joey Blankenship [mailto:[EMAIL PROTECTED] Sent: Friday, September 10, 2004 2:48 PM To: [EMAIL PROTECTED] Subject: RE: [sqlite] Encrypting data stored in database I'm including the routines that we modified. I hate to send the whole file around the entire list. The ppdbuffer and ppdbuffersize are set initially when the database is opened and closed. The current implementation may not be threadsafe, but we are single threaded. extern int ppdbuffersize; extern void *ppdbuffer; int sqlite3OsRead(OsFile *id, void *pBuf, int amt){ DWORD got; int i; assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); TRACE3("READ %d lock=%d\n", id->h, id->locktype); if( !ReadFile(id->h, pBuf, amt, &got, 0) ){ got = 0; } // PPD - XOR the buffer with a pattern so the disk file contents are not in plain text for (i = 0; i < got/4; i++) { *((DWORD *)((DWORD *)pBuf + i)) = (*((DWORD *)((DWORD *)pBuf + i)))^0xA5A5A5A5; } // XOR the buffer with a pattern - any leftover bytes for (i = 0; i < got%4; i++) { *((BYTE *)((BYTE *)pBuf + i)) = (*((BYTE *)((BYTE *)pBuf + i)))^0xA5; } if( got==(DWORD)amt ){ return SQLITE_OK; }else{ return SQLITE_IOERR; } } int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){ int rc; DWORD wrote; int i; if (ppdbuffersize < amt) { ppdbuffersize = amt + 1024; ppdbuffer = realloc(ppdbuffer, ppdbuffersize); } // PPD - XOR the buffer with a pattern so the disk file contents are not in plain text for (i = 0; i < amt/4; i++) { *((DWORD *)((DWORD *)ppdbuffer + i)) = (*((DWORD *)((DWORD *)pBuf + i)))^0xA5A5A5A5; } // XOR the buffer with a pattern - any leftover bytes for (i = 0; i < amt%4; i++) { *((BYTE *)((BYTE *)ppdbuffer + i)) = (*((BYTE *)((BYTE *)pBuf + i)))^0xA5; } pBuf = ppdbuffer; assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); TRACE3("WRITE %d lock=%d\n", id->h, id->locktype); while( amt>0 && (rc = WriteFile(id->h, pBuf, amt, &wrote, 0))!=0 && wrote>0 ){ amt -= wrote; pBuf = &((char*)pBuf)[wrote]; } if( !rc || amt>(int)wrote ){ return SQLITE_FULL; } return SQLITE_OK; } At 03:03 PM 9/10/2004, you wrote: >Joey, > >Would you mind sharing the modifications you made to the os_win.c file? >I would be interested in using such a modification, unfortunately, c++ >isn't my strongest language. > >Thanks! > >Bob