Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 16.2 ('StockScripter')
Instant purchase and download via GumRoad!

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 Einhugur e-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 like myString.EncryptBlowfish for encypting without a password, or myString.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.