public void SerializeTheSameAsSqlServer(int plaintext) { SqlIntSerializer serializer = new SqlIntSerializer(); byte[] serializedPlaintext = serializer.Serialize(plaintext); byte[] expectedCiphertext = deterministicEncryptionAlgorithm.Encrypt(serializedPlaintext); Database.Insert(new SqlParameter("@parameter", SqlDbType.Int) { Value = plaintext }); byte[] actualCiphertext = Database.SelectCiphertext(SqlDbType.Int); Assert.Equal(expectedCiphertext, actualCiphertext); }
/// <summary> /// Serializes the provided <paramref name="value"/> /// </summary> /// <param name="value">The value to be serialized</param> /// <returns> /// An array of bytes with length 8. /// </returns> public override byte[] Serialize(int?value) { return(value.IsNull() ? null : serializer.Serialize(value.Value)); }