Ian,

I appreciate the code. Basically, this is the long and short of what I want to do. I plan to use an RBDB to store preferences, registration information, etc, but I want the DB encrypted at all times unless in use. So I need a mechanism by which to Encrypt/ Decrypt the DB file and read/write to the file on the fly, etc. Any leads, or suggestions?

Regards,
Michael


On Mar 11, 2006, at 8:09 AM, realbasic-nug- [EMAIL PROTECTED] wrote:

Message: 18
Subject: Re: Einhugur Plugins (e-Cryptit)
From: Ian Piper <[EMAIL PROTECTED]>
Date: Sat, 11 Mar 2006 12:43:16 +0000

Hi Michael,

Here is a code snippet. You pass in the plaintext and the key and it
returns a Blowfish-encrypted string. BTW it also enhexes the string
so that you can pass the string around more easily. UserEncrypter,
BTW, is a string that getes generated elsewhere in the application
and is just used to pad out the string so that the important part of
the plaintext is divisible by 8.


==== end snippet ====
Function encipher(plaintext As String, key As String) As String
   Dim bf As BlowfishCBC

   dim sPlaintext As String
   dim sEncrypted As String
   dim sEncryptedHex As String

   // initialise a new Blowfish object using the key
   bf = new BlowFishCBC(key)

   // Add 7 extra bytes to ensure that Blowfish will encrypt the
   // entire string if its not dividable by 8
   // (this is actually overkill since we determine the string length)
   sPlaintext = plaintext + mid(userEncrypter,1,7)

   // now encrypt the key supplied
   sEncrypted = bf.Encrypt(sPlaintext) + bf.FinishEncrypt()

   // and hex
   sEncryptedHex = DoLocalHex(sEncrypted)

   // send the encrypted and hexed string back to the calling method
   return sEncryptedHex

   // Reset the encryptor so if can be safely used again
   bf.Reset
End Function
==== end snippet ====

I hope this helps.


Ian.
--
Dr Ian M Piper
[EMAIL PROTECTED]
skype: ianmpiper
--
Where is the wisdom we have lost in knowledge?
Where is the knowledge we have lost in information?

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to