Page 1
Encryption within eVB or VB.NET
Data security may be a vital aspect
to your mobile application. Maybe you want to protect your
data in the event that your device gets lost, or you want
to protect it if you're transferring it over the Internet.
Sapphire
Solutions Ltd have developed an easy-to-use utility
that can encrypt or decrypt files or text strings. This
utility is also available for Windows so you have encrypt
or decrypt files in your back-end system as well.
Overview
You can download the demo
project of the Sapphire Encrypt DLL
which includes a personal use version of the utility. This
utility can be linked into eVB, VB.NET or Visual Basic 6.0
so you can protect the data in your application right away.
Running the Project
After downloading and unzipping the
Sapphire Encrypt demo project, you need to add the appropriate
version of the SapphireEncrypt.DLL to the
\Windows directory on your Pocket PC. If
you are using VB.NET, you will need to include the SapphireEncrypt.DLL
into the application directory of your program instead.
You can find the correct DLL in the unzipped project directory
under the appropriate sub-directory. Once you have done
this you can run the desired project file on the client
device.


The demo project shows how to encrypt
and decrypt a file or text string. If you are running a
local database on your Pocket PC, for example, Pocket Access,
then you can simply encrypt the file using a password when
the application is not in use.
The Code
To implement Encrypt functionality in
your own eVB or VB.NET application you only need to create
a few simple calls to the DLL.
Example: Linking the DLL using VB.NET
<DllImport("SapphireEncrypt.dll")>
_
Public Function sEncryptFile(
_
ByVal sSource As
String, _
ByVal sDestination
As String, _
ByVal sKey As
String, _
ByVal lLicence
As Integer, _
ByVal bMessages
As Byte) As
Integer
End Function
Example: Linking the DLL using eVB
Declare Function
sEncryptFile _
Lib "SapphireEncrypt.dll"
( _
ByVal sSource As
String, _
ByVal sDestination
As String, _
ByVal sKey As
String, _
ByVal lLicence
As Long, _
ByVal bMessages
As Byte) As
Long
A simple example on how to encrypt a
file is shown below:
lEncrypted = sEncryptFile(sSource, sDest,
sKey, lLicence, True)
- lEncrypted contains the
number of a success or failure. 0= successful, 1= failed.
- sSource is the filename
of the file to encrypt.
- sDest is the filename of
the resulting encrypted file.
- sKey is the password that
must be used to decrypt the file later.
- lLicence is the licence
number for registered users of the utility. For the demo
project, this will be 1234567890.
- bMessage is a value stating
whether to allow the DLL to display and messages or handle
them within the VB project.
Where to find the demo
The product information page for the
latest Sapphire Encrypt utility allows you to download the
personal use version that includes the sample eVB and VB.NET
projects with the demo version of the DLL for each target
platform. This can be found at www.sapphire-solutions.co.uk/product.asp?product=ENCRYPT.
Licence of use
For those that wish to simply experiment
with the utility or use it for personal projects, you can
use the utility absolutely free of charge.
For those that wish to include the utility
into their own commercial applications, they can purchase
a royalty-free licence for the utility online at http://www.sapphire-solutions.co.uk.
This is a one off payment that allows you to distribute
it in any projects created under the registered company.
Please refer to the web site for the latest prices.
Other utilities you may find useful
Sapphire Solutions Ltd have a variety
of other utilities that you may find useful or vital to
your application. Some of these are:
- Sapphire
RAS - Dial up a remote connection and manage phone
book.
- Sapphire
FTP - Communicate with a FTP server (includes directory
navigation).
- Sapphire
GZip - Compress and decompress files into .gz or .zip
format.
- Sapphire
IrDA - Use your application to print on an IrDA enabled
printer.
- Sapphire
Buttons - Take control of other buttons on your device.
Please check www.sapphire-solutions.co.uk
for a full listing of available products.