How to open an old project from 2006 with Gambas 3.11.4?

Post Reply
Godzilla
Posts: 6
Joined: Wednesday 26th September 2018 11:20am

How to open an old project from 2006 with Gambas 3.11.4?

Post by Godzilla » Saturday 08th December 2018 5:35pm

I was researching encryption and decryption in Gambas. Both functions don't appear to exist in Gambas.

I found an old project from 2006 in the Gambas mailing list archives, where old VB source code for AES encryption/decryption was "Gambasized" and is said to work, according to the message. This would be perfect for me to play around with.

The problem is, I can't get Gambas 3.11.4 to recognize and open this old project. I created a new project, pasted the contents of CRijndael.class into a new class. Attempted to init and call it from within the program, using the contents of FrmMain.class as a guide. But I get nothing but syntax errors from CRijndael.class. Is Gambas code from back then not compatible with Gambas 3?

The project is found as an attachment (gambasCrypt.tar.gz) to this message:

https://sourceforge.net/p/gambas/mailma ... /14531138/

Thanks for reading.

stevedee
Posts: 90
Joined: Monday 20th March 2017 6:06pm

Re: How to open an old project from 2006 with Gambas 3.11.4?

Post by stevedee » Sunday 09th December 2018 10:55am

Godzilla wrote:
Saturday 08th December 2018 5:35pm
...Is Gambas code from back then not compatible with Gambas 3?...
I think there may be backwards compatibility issues between Gambas 3 >> 2 >> 1

Can you zip your project and post it here?

User avatar
cogier
Site Admin
Posts: 205
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: How to open an old project from 2006 with Gambas 3.11.4?

Post by cogier » Sunday 09th December 2018 12:37pm

I have messed about with the code from here https://sourceforge.net/p/gambas/mailma ... -QL6ZhO/1/

The issues I found: -
There were lots of Var as Byte[] which need to be Var as New Byte[]
This line I changed from
RETURN m_ptab[(CLng(m_ltab[x]) + CLng(m_ltab[y])) MOD 255]
To
RETURN m_ptab[(CLong(m_ltab[x]) + CLong(m_ltab[y])) MOD 255]
The Form is in a mess. I have created something similar.

The code I have modified does encrypt but I have no idea how to decrypt but hopefully this is a start.
Image
CryptTest.tar.gz
(24.47 KiB) Downloaded 3 times

Godzilla
Posts: 6
Joined: Wednesday 26th September 2018 11:20am

Re: How to open an old project from 2006 with Gambas 3.11.4?

Post by Godzilla » Monday 10th December 2018 12:30am

cogier, you've done it! Your project does encrypt and decrypt without any further modification.

Playing around with it, I discovered the way to decrypt is to 1) encrypt some text 2) erase the contents of txtClear.Text, while leaving the other fields unchanged 3) click the decrypt button, which outputs the decrypted text into txtClear.Text.

TextBox1 seems to serve no purpose other than that of a label. It came in handy to check the length of the encrypted text, out of curiosity (avoiding the Print command). Turns out the minimum length of the encrypted text is 64 characters. However, if the unencrypted text length > 28 then the encrypted length grows to 128, then 192, etc. In my tests, the password length seems to have no effect on the length of the encrypted text.

I noticed that attempting to decrypt with an incorrect password gives a NULL error in CRijndael.class. To assist anyone in the future who finds use for this code, I modified CRijndael.class in the DecryptString section, to avoid this error:

Code: Select all

If bytOut <> Null Then
    For ix = 0 To bytOut.Count - 1
        strDecriptedText &= Chr(bytOut[ix])
    Next
Else
    strDecriptedText = "Password incorrect."
Endif
In the original post from 2006, the author mentioned of the speed of this code was an issue. In my tests, both encryption and decryption of even long strings of text seems instantaneous in the Gambas IDE. Even below the measurable limits of a timer. I attribute this to modern hardware, modern Linux, and a much more optimized version of Gambas. No doubt, performing these functions on something huge like a file of several mB would undoubtedly begin to show a measurable lag.

cogier, thank you once again for lending your knowledge to solve a problem I could have never figured out.

Post Reply