// Check AES Keys for unicity public void TestUniqueAESKeys() { int numKeys = 100; List <KeyParameter> keys = new List <KeyParameter>(); for (int i = 0; i < numKeys; i++) { KeyParameter k = KeysHelper.generateAesKey(); keys.Add(k); Assert.IsTrue(k.GetKey().GetLength(0) == 32); } Dictionary <String, KeyParameter> keysBytes = new Dictionary <String, KeyParameter>(); keysBytes = keys.ToDictionary ( //Define key element => Convert.ToBase64String(element.GetKey()), //Define value element => element ); Assert.IsTrue(keysBytes.Count == numKeys); }