AES 128 Bit CBC Mode Encrypt/Decrypt

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Brianwuz
Newbie
Posts: 1
Joined: Mon Sep 25, 2017 4:42 pm

AES 128 Bit CBC Mode Encrypt/Decrypt

Post by Brianwuz »

I had a qb4.5 program that I needed to add Decrypt/Encrypt to. I needed to read in a registration.dat file, decrypt it, modify a few bytes of the data, re-encrypt it and write it to a license.lic file. I was not trying to crack the encryption as I knew the encryption keys and initialization vector. I just needed to implement the process in basic. I searched all over google and nothing for quick basic. I found a visual basic program that would do it and I could modify it, but my program is huge and I am not going to re-write it in visual basic (I don't know vb very well either). I am not very good at higher math and do not understand the formulas for the AES Encrypt/Decrypt. I felt stupid just looking at them. I started watching a lot of college lectures on AES Encryption on YouTube. I found a step by step example for CBE mode Encryption for a single 16 byte block which was very helpful in verifying my program worked. After I got the Encrypt working, I just followed the data backwards to get the Decrypt working. Then I needed to add in the Initialization Vector for CBC mode. It is now working. Is anyone else interested in AES in Quick Basic? It can be made to do ECB or CBC Mode. It does 128 bit but could be made to do 192 or 256 bit with some additions/mods. Need to generate 12 or 14 subkeys instead of 10 and run 12 or 14 rounds instead of 10. These are subroutines and not the fancy QB4.5 subs, just the old basic subs. It could be made into a library but I have never made a library. Probably have to make proper subs first.

Brian
Post Reply