about encryption

Jochen Peters j.peters at valentina-db.de
Tue Sep 16 17:40:54 CDT 2003


Hi Ruslan,
Hi Carlo,

>> I'm trying to encrypt a db (V4RB) but with very very very little 
>> success.
>>
>> 1.  I create a new db :
>>    res = librDatabase.Create(f, 1, 32768)
>>    librDataBase.ChangeEncryption("","myEncryptionKey")
>>
>> 2. A new encrypted db is created, and after closing it I can open it
>> again with:
>>    librDataBase = new MyDataBase
>>    librDataBase.SetEncryption("myEncryptionKey")
>>    res = librDataBase.Open(f)
>>
>> The problem starts if I want to get a message-window showing up at
>> opening-time asking the user for the encryption-key, and if the user
>> types the right key, then the db will open, otherwise no.
>> For this purpose I follow a very annoying way:
>>
>>   librDataBase = new MyDataBase
>>   librDataBase.SetEncryption("wrongPass")
>>    res = librDataBase.Open(f)
>>    if not res then
>>      if librDataBase.ErrNumber = 326 then
>>        librDataBase = nil
>>        wp = new PasswordWindow
>>        wp.ShowModal
>>        //the user types the inNewKey and opens the db
>>      end
>>   end
>
> I think you can use simpler:
>
>     librDataBase = new MyDataBase
>     res = librDataBase.Open(f)
>     if librDataBase.ErrNumber = 326 then
>          librDataBase = nil
>          wp = new PasswordWindow
>          wp.ShowModal
>          //the user types the inNewKey and opens the db
>     end
>
> You do not need try assign wrong password, because empty password 
> already is
> wrong.
Yes - i do it in the same way in vStudio (but using C++ execptions..)

>> As you can see, I pass a wrong inNewKey in order to force an error
>> (326) and by that to have the message-window show up.
>>
>> I dont like the procedure, but I could do with it. But how to create
>> a new db with no inNewKey, as in
>>     librDataBase = new MyDataBase
>>    librDataBase.SetEncryption("")
>>    res = librDataBase.Open(f)
>>
>> How can the user open it without getting the message-window? In fact,
>> the above open-code relied on a wrong inNewKey to force the
>> message-window to show up, but in this case I dont need it at all.
>
> I think you need simply:
>
>      librDataBase = new MyDataBase
>      if( password is not empty )
>         librDataBase.SetEncryption("")
>      res = librDataBase.Open(f)
>
> So if there was no assigned password on creation you will NOT call
> SetEncryption() and you will get normal NOT encrypted db.
>
> And my above code will try to open it with NO assignment of wrong 
> password.
Yes - correct.

>
-- 
Best regards,
Jochen Peters
PIIT GmbH

------------------------------------
http://www.valentina-db.de



More information about the Valentina mailing list