Article Preview
Buy Now
COLUMN
Encryption with Xojo
Using M_Crypto for Xojo
Issue: 16.2 (March/April 2018)
Author: Scott Boss
Author Bio: Scott Boss is the founder of Nocturnal Coding Monkeys, Llc, who specialize in writing custom software. Scott has been a developer, system administrator, storage engineer, consultant, and architect to businesses from startup to global 100.
Article Description: No description available.
Article Length (in bytes): 6,913
Starting Page Number: 100
Article Number: 16210
Related Link(s): None
Excerpt of article text...
This month we are going to discuss encryption (and hashing) with Xojo. We have several options. First option is to use the Xojo provided crypto classes. They work well, but are very limited on what they support. The classes support hashing using MD5, SHA1, SHA256, and SHA512. Xojo also supports BER and RSA encryption.
The second option is to use a commerical plugin like Monkeybread's
Encryption
plugin and Einhugure-CrytptIt
Engine. Both have lots of options, but they have two drawbacks. The first is they cost money and some of us are on a budget. Now good plugins are worth the money, but the second problem is they can't be used with open source projects as they are not open source nor free. However, depending on your project, these issues might not be problems.The third option is what this column is about this month. Kem Tekinay wrote and released
M_Crypto
for Xojo. Kem started this project by writing a class for doing Blowfish for Xojo. Over time Kem expanded it to include more encryption and hashing types. Now it supports Blowfish, AES, Bcrypt, and Scrypt.Doing AES encryption by a plugin is going to be faster than something that is written purely in Xojo, as the plugin is optimized for speed, but for what most of us are doing around encryption and hashing, the speed difference is not really noticable. Where you would notice the difference is, if you are encrypting/decrypting a very large file or if you are doing a large set of files, or if you are doing work on a lower-powered machine like a Raspberry Pi.
As with all of Kem's modules and classes, he has a very good sample program to demostrate the functionality. As you can see, there are lots of options when you look at Figure 1. In that picture, I am using the Blowfish encryption to encrypt part of the module's documentation. If you look at the lower right hand corner of the picture, you can see it only took a quarter of a second (0.25) to encrypt the data.
If we look at the
EncryptBlowfish
code, we can see a fairly simple method to extend the string class to allow you to encrypt the string. You can either do something likemyString.EncryptBlowfish
for encypting without a password, ormyString.EncryptBlowfish( "secret password" )
for encrypting the string with a password. This makes it nice since you can do the encryption inline on your string.
...End of Excerpt. Please purchase the magazine to read the full article.