private static void RunTestGetBytesToUInt64(ulong value, string expectedHex) { var expectedBytes = StringToBytesConverter.ConvertToByteArray(expectedHex); var result = BigEndianBitConverter.GetBytes(value); Assert2.AreElementsEqual(expectedBytes, result); }
private static void RunDecryptSymmetric(string ciphertextResourceName, string plaintextResourceName, string passphrase) { var ciphertext = GetTestDataAsByteArray(ciphertextResourceName); ciphertext.ShouldNotBeNull(); ciphertext.Length.ShouldBeGreaterThan(0); var plaintext = GetTestDataAsByteArray(plaintextResourceName); plaintext.ShouldNotBeNull(); plaintext.Length.ShouldBeGreaterThan(0); var cipherStream = new MemoryStream(ciphertext); var outputStream = new MemoryStream(); var result = Simple.Decrypt(cipherStream, outputStream, new MockSecretDataProvider(passphrase)); result.ShouldNotBeNull("Result of symmetric decryption is null"); result.IsSuccessful.ShouldBeTrue("Symmetric decryption failed"); result.IsSigned.ShouldBeFalse("Expected no signature, but found one"); result.IsSignatureGood.ShouldBeFalse("Expected bad signature, but found good one"); var outputLength = (int)outputStream.Length; outputLength.ShouldBe(plaintext.Length); var compare = new byte[outputLength]; outputStream.Seek(0, SeekOrigin.Begin); outputStream.Read(compare, 0, outputLength); Assert2.AreElementsEqual(plaintext, compare); }
public void VerifyClrCorrectlyDecodesRadix64() { Assert2.AreElementsEqual(StringToBytesConverter.ConvertToByteArray("14FB9C03D97E"), Convert.FromBase64String("FPucA9l+")); Assert2.AreElementsEqual(StringToBytesConverter.ConvertToByteArray("14FB9C03D9"), Convert.FromBase64String("FPucA9k=")); Assert2.AreElementsEqual(StringToBytesConverter.ConvertToByteArray("14FB9C03"), Convert.FromBase64String("FPucAw==")); }