Exemple #1
0
    public void No_EncryptedContents_Returns_Empty_Json()
    {
        // Arrange
        var box = new Locked <string>();

        // Act
        var result = box.Serialise();

        // Assert
        var some = result.AssertSome();

        Assert.Equal(JsonF.Empty, some);
    }
Exemple #2
0
    public void Returns_Json()
    {
        // Arrange
        var value = Rnd.Str;
        var key   = CryptoF.GenerateKey().UnsafeUnwrap();
        var box   = new Locked <string>(value, key);
        var json  = string.Format("{{\"encryptedContents\":\"{0}\",\"salt\":\"{1}\",\"nonce\":\"{2}\"}}",
                                  Convert.ToBase64String(box.EncryptedContents.UnsafeUnwrap()),
                                  Convert.ToBase64String(box.Salt),
                                  Convert.ToBase64String(box.Nonce)
                                  );

        // Act
        var result = box.Serialise();

        // Assert
        var some = result.AssertSome();

        Assert.Equal(json, some);
    }