about encryption

Ruslan Zasukhin sunshine at public.kherson.ua
Tue Sep 16 14:11:54 CDT 2003


on 9/16/03 13:56, Carlo Rubini at osb at bttb.net.bd wrote:

Hi Carlo,

I have CC this to Jochen, I know he have implement this in Vstudio,
So may be he will correct me and you.

> Ruslan,
> 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.
 
> 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.

> Ruslan, I'm completly confused!
> 
> I tried to use the encrypted boolean, as in:
> if librDatabase.encrypted then...
> 
> but the computer freezes.
> 
> Can you help me out?  Thanks,

-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list