Browsed by
Category: C#

RijndaelManaged, AesManaged, and AesCryptoServiceProvider – SimpleAccountLocker App

RijndaelManaged, AesManaged, and AesCryptoServiceProvider – SimpleAccountLocker App

I recently wanted to write a small app to become more familiar with .NET encryption/decryption libraries. As a result, I created a quick little account locker app which stores manually entered account data locally. Sure, there are great services available which do this already and automate the process, i.e. last pass, for saving passwords securely across multiple devices – however, SimpleAccountLocker is an extremely minimal app which provides the basis to store data locally if you do not wish to save off-site; likewise, it was a fun little way to play with some security libraries.

You can view the app on my GitHub: https://github.com/MrChrisHammond/SimpleAccountLocker

To begin, .NET offers many different encryption classes, however, for this app’s purpose, the main AES classes I tested out include:

– RijndaelManaged
– AesManaged
– AesCryptoServiceProvider

All three of these are based on AES – a specification for encryption created by the US National Institute of Standards and Technology (NIST) in 2001. This method of encryption is symmetric and allows data to be encrypted and later decrypted with a key and initialization vector. This is helpful when you have data you wish to store securely but have a later need to decrypt and read it – for example, an instant message. Nonetheless, within the aforementioned classes are a few differences. For instance, RijndaelManaged allows you to set a different block size whereas AesManaged maintains the same fixed blocksize of 128 so-as not to compromise security. However, AesManaged is actually based on RijndaelManaged.

In terms of compliance, AesCryptoServiceProvider uses a library which is FIPS compliant1 whereas RijndaelManaged and AesManaged do not.  If you are not familiar with FIPS, you might be wondering – what is it? The Federal Information Processing Standard is a set of rules which sets the requirements on approving cryptographic modules. Although this is a US government standard, here in Canada the Communications Security Establishment (CSE) uses FIPS 140-1 and 2 as part of its certification2.

In code, all three of these can be used to encrypt data with an ICryptoTransform transformation, CryptoStream decorator, and using a key and Initialization Vector (IV). Below is a  comparison of AesCryptoServiceProvider vs RijndaelManaged within SimpleAccountLocker.

 

Boids – 2D Unity Approach

Boids – 2D Unity Approach

Boid’s model was created in 1986 by Craig Reynolds to simulate the behaviour of birds as they group together in a flock. The model has three key methods to mimic real life bird flock behaviour. These methods include:

a) Maintaining a heading based on the averaged direction of surrounding boids.
b) Maintaining a separation so boids do not overlap.
c) The boids must maintain a cohesiveness with the flock by steering towards the centre position of surrounding flockmates.

The behaviour also operates similar to schools of fish or other wildlife. As a game developer, this can be useful when implementing enemy mob behaviour and in my case, I used this approach to simulate flocks of zombies in 2d space as seen in the mp4 above.

The concept isn’t too difficult, below I’ve posted two implementations. I’ve implemented it using rigidbody2d but I’ve also included the code for using it without rigidbody force.

  1. Boid Class for use with Rigidbody2D
  1. Boid Class for use with kinematic