Oh, it actually works

Programming, software, and related topics.

The Pitfalls of System.Random

When it comes to random number generators in .NET, there's two options: System.Random and the easy to say System.Security.Cryptography.RNGCryptoServiceProvider. The former is a pseudo random number generator (PRNG), while the latter is a cryptographically secure random number generator (CSRNG). Common wisdom is to use Random, since it's faster and friendlier than RNGCryptoServiceProvider while still providing random numbers that are good enough for casual use. Unfortunately, Random is not as random as you'd like, performance leaves a lot on the table, and the API isn't nearly as nice once you get to know it.

Connect to a PostgreSQL cluster with a custom CA Cert using .NET Core

Sometimes we want to connect to a PostgreSQL database through SSL/TLS, but the database's CA Certificate aren't trusted by the computer. This is the case with DigitalOcean's Managed Database offerings. There are a couple different ways to solve this. First, you can simply use sslmode=require to skip verification; however, this opens the application up to man-in-the-middle attacks, as it can't verify the server's identity. The second way is to verify the root certificate ourselves by hooking one of Npgsql's callbacks.

'Mars Rover' Simulation AI

When I was a college freshman, we had to take an introductory course to computer science. The course covered many different topics, such as sorting algorithms, internet of things, and artificial intelligence. For AI, we were given a prebuilt 2D "Mars Rover" simulation to write an AI for. Unfortunately since this was an introductory class, we weren't expected to know how to program with actual programming languages yet - instead we got use Scratch 2 for all of our assignments.