A Data Encryption Program
In this section, we build a more practical example that uses the encryption routines in the Palm OS to safeguard both memory and database records. We expand on the previous simple example to show how to use feature memory to store larger data structures. And we package the VB code as a module—a BAS file—so other applications can use our encryption and decryption routines.
DES
Palm included the US government Data Encryption Standard (DES) as part of its operating system. Although DES is an older cryptographic standard, it is adequate for providing security in many situations.[57] Technically, we are using the DES electronic codebook mode (ECM); this means that each block of text can be encrypted or decrypted independently. We provide some cryptography references at the end of the chapter that discuss DES and other encryption algorithms in some detail.
DES is a block cipher—it encrypts and decrypts data in blocks of 8 bytes. It requires a key to operate; in fact, it uses the same key to encrypt and decrypt data. The DES key is 56 bits long and consists of eight 7-bit bytes (for historical reasons, the algorithm ignores one bit of each key byte). The DES key must be kept secret, because anyone who has it can decrypt the data. For this reason, we won’t store the key in our code, but instead will require the user to enter it into a program when it is running.
Encryption and decryption of text blocks is simple under DES: merely provide the 56-bit key and 8 ...
Get Programming Visual Basic for the Palm OS now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.