Search Results (5 posts found):
After a few months of not looking at it, I've recently been working on making a few old-school improvements to Barkout, namely a continue code-style save game mechanism, and a new power up in the form of a multi-ball bonus, common in most other Arkanoid clones.
Above, the multi-ball powerup in action.
Below, using the Continue screen to enter a code.
The purpose of Barkout all along has simply been to get some practice in C programming. Initially, it was so I could help a family member who had started a C programming course at university, but it then evolved into doing it just because I enjoyed it. C is a great language to program in. It's also just a nostalgia trip for me; trying to program the sorts of games that I played on my first computer in the 80s: an Amstrad CPC6128.
Anyway, the fruit of my effort is that Barkout version 1.2.0 has now been released and can be found by following the "Free Games!" icon in the top menu.
I recently needed to implement RSA cryptography in Delphi, sticking to a few requirements of my own choosing:
1. The library used should be free
2. The library license should be permissive enough that I can use the library in a commercial application
3. The library should have as few extra files to include as possible
I looked initially at LockBox, but it came with a multitude of files to either copy to my source folder or include in my library path. I don't want other developers in my team to have to add yet more third party libraries, so I gave this a miss. Additionally, the documentation wasn't great and finding example online was quite tricky.
I then tried PGPCrypt, but could only find a version of that for Lazarus, the free Delphi compiler.
Next was the TMS Cryptography pack, but this isn't free, so again a non-starter.
Then I thought about OpenSSL. We already use OpenSSL as a DLL for a different, but related, purpose so the file is already present in our source and program folder. What we don't have are function headers as we're calling the DLL functions by importing them directly (we only use three at present), but RSA is more complicated and uses a particular structure that would need replicating in Delphi. I thought this might mean OpenSSL was also a non-starter, but after much searching online I came across the Delphi-OpenSSL project at https://github.com/UniGe/delphiopenssl/ which consists really of only three .pas files, only one of which is necessary for what I'm trying to implement: RSA encryption and decryption. For this purpose I need use only the LibEAY32.pas file coupled with the LibEAY32.dll file. We're using version 1.0.2 of this, and the Delphi-OpenSSL project is compatible with that. Great!
I needed to make a few minor changes, as despite the programmers' best efforts it seemed confused about the difference between Char and AnsiChar in Delphi 2009, but the changes were minimal and consisted, almost entirely, of me replacing references to PChar or PCharacter with PAnsiChar.
The next challenge was to see if I could use an existing key to encrypt a file.
I added my modulus, public exponent and private exponent (not needed for encryption) as Base64 encoded string constants and used:
_rsa = RSA_New();
to create a new RSA structure to populate with the key information. This actually returns a pointer to an RSA object, so it needs both dereferencing and casting when used. The properties we're interested in are the modulus, n; the public exponent, e; and the private exponent, d (when decrypting, later).
These properties take the form of BigNum objects as they can be sometimes thousands of bits long. The BigNums need to be created before being used:
RSA(_rsa^).n := BN_New();
RSA(_rsa^).e := BN_New();
The Base64 values were then decoded and altered, one byte at a time, to hex using IntToHex (which returns a string) and then BN_HexToBN was used to set the RSA record's properties accordingly:
BN_HexToBN(RSA(_rsa^).n, ansistring(public_modulus));
BN_HexToBN(RSA(_rsa^).e, ansistring(public_exponent));
The input string can then be encrypted by calling:
enc_in := SysUtils.TEncoding.ASCII.GetBytes(string(input_text));
to get the string character values as a byte array, followed by:
RSA_Public_Encrypt(length(enc_in),PAnsiChar(enc_in), PAnsiChar(@textout),_rsa,RSA_PKCS1_PADDING);
to do the actual encryption. The output cypher text is held in textout. This will look like garbage but can be converted to a Base64 string for convenient storage.
And that's it.
Two caveats:
I had to add an extra property to the RSA record to match the version of OpenSSL we're using. This was:
engine: pointer;
below the meth property.
And I had to initialise the SSL library by calling:
SSLEay_version(_SSLEAY_VERSION);
before making any calls to encryption or decryption routines. There's probably a better way to do this, but this did the trick.
I put this information here in the hope that it helps someone else who struggled as much as I did to implement this!
Happy New Year!
A new year, a new start, and some New Year's Resolutions (Addunedau Blwydden Newydd) to think about.
Actually I have four. One is a carry-over from last year as I singularly failed to achieve it!
1. Cycle across the Severn Bridge. The first / original Pont Hafren allows pedestrian and cycle traffic in addition to motor vehicles. It's been my plan to cycle over it for about three years now but I've not yet found the time to do it.
2. Make more of an effort to improve my Welsh. I've done very little in the past twelve months to actually improve my Welsh, and in some respects my ability has gone backwards in that words I used to know don't spring to mind in the same way they used to.
3. Write a short story. Just to prove to myself that I can stick at a task like that long enough to finish it.
I think that's enough for now. Number 1 in particular is something I'm itching to do, if only to take photos of the Second Severn Crossing (I refuse to call it "The Prince of Wales Bridge") from the first.
As an extra bit, I also want to take some photos of the Newport transporter bridge all lit up at night, but that's not really a resolution.
I admit, I've been a bit remiss in both updating this site and in learning Welsh.
The problem is finding the time.
A while ago, back in July, I lost my DuoLingo streak of more than two years and with it any incentive to keep up with my DuoLingo practice.
I suppose that's the problem with DuoLingo: once the addiction of keeping your streak going wears off, and if you've already completed the language tree, there's not much to keep you going back, as it's all just more of the same.
I could have carried on with Say Something In Welsh, but again it's finding the time. I used to do it while driving, but I generally prefer to listen to radio comedy these days, so my Welsh gets neglected.
And I know my Welsh is suffering for it, as I keep encountering words that I know I know, but of which I can suddenly no longer remember the meaning.
I need to make more of an effort. I'll keep you posted!
If you're learning a language, one of the best ways to gain exposure to that language and increase fluency is to visit a country where that language is spoken.
Herein lies the problem with Welsh: not all Welsh people speak it. They all speak English, but only around 20% of the population speaks Welsh. This means that if I'm in Wales, I can't initiate a conversation in Welsh because I can't guarantee that the other person will be a Welsh speaker.
Such a situation, where a native does not speak the native language, would be inconceivable in most other countries.
The fact that there are no monoglot Welsh speakers remaining also doesn't help. Because everyone speaks English fluently there's less incentive to make the effort to learn and speak Welsh.
Then there's the problem with signage. In France, other than at some touristy areas, all signs are in French. Signs alerting me to the "dèrniere sortie avant péage" will do so only in French. Translating and understanding the signs becomes part of the learning experience. Unfortunately, in Wales most signs are bilingual. The order of the languages is left to the discretion of the local authority, but an English translation will be on the sign somewhere. On the one hand, this allows you to quickly confirm that your translation of the Welsh was correct. On the other, it takes a lot of the fun and the necessity out of translating in the first place. It's very hard not to notice the English accidentally before you've had chance to attempt the Welsh.
What I have discovered, to my surprise and delight, is that several of my colleagues speak varying levels of Welsh. Remember, this is Somerset, England, not the north of Wales, so it's not entirely expected. One even speaks fluent Welsh, having attended a Welsh medium school. And he's said he's always happy to help with my Welsh learning.
So things are looking up.