diff --git a/.gitignore b/.gitignore
index 9491a2f..1019e33 100644
--- a/.gitignore
+++ b/.gitignore
@@ -360,4 +360,5 @@ MigrationBackup/
.ionide/
# Fody - auto-generated XML schema
-FodyWeavers.xsd
\ No newline at end of file
+FodyWeavers.xsd
+/TestPrivateBinMarkdown
diff --git a/PrivateBinSharp.sln b/PrivateBinSharp.sln
index 466b88a..f0d01c2 100644
--- a/PrivateBinSharp.sln
+++ b/PrivateBinSharp.sln
@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33403.182
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrivateBinSharp", "PrivateBinSharp\PrivateBinSharp.csproj", "{45153CEC-DFAE-4623-809A-8D4BD2D811A3}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrivateBinSharp", "PrivateBinSharp\PrivateBinSharp.csproj", "{45153CEC-DFAE-4623-809A-8D4BD2D811A3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestPrivateBinMarkdown", "TestPrivateBinMarkdown\TestPrivateBinMarkdown.csproj", "{47579373-3E2E-44DA-9C95-3EADB83448FD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +17,10 @@ Global
{45153CEC-DFAE-4623-809A-8D4BD2D811A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45153CEC-DFAE-4623-809A-8D4BD2D811A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45153CEC-DFAE-4623-809A-8D4BD2D811A3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {47579373-3E2E-44DA-9C95-3EADB83448FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {47579373-3E2E-44DA-9C95-3EADB83448FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {47579373-3E2E-44DA-9C95-3EADB83448FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {47579373-3E2E-44DA-9C95-3EADB83448FD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/PrivateBinSharp/PrivateBinClient.cs b/PrivateBinSharp/PrivateBinClient.cs
index d325f00..41a4240 100644
--- a/PrivateBinSharp/PrivateBinClient.cs
+++ b/PrivateBinSharp/PrivateBinClient.cs
@@ -50,18 +50,24 @@ public PrivateBinClient(string hostUrl)
///
public static string Version => Assembly.GetExecutingAssembly().GetName().Version!.ToString(3);
- ///
- /// Create a paste that will be encrypted
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public async Task CreatePaste(string text, string password, string expire = "5min", bool openDiscussion = false, bool burnAfterReading = false)
+ ///
+ /// Create a paste that will be encrypted
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task CreatePaste(string text,
+ string password,
+ string expire = "5min",
+ bool openDiscussion = false,
+ bool burnAfterReading = false,
+ string format = "plaintext")
{
if (string.IsNullOrEmpty(text))
throw new ArgumentException("Paste text can't be empty.");
@@ -87,14 +93,14 @@ public async Task CreatePaste(string text, string password, string expire
Tuple Json;
try
{
- Json = GeneratePasteData(text, password, expire, openDiscussion, burnAfterReading);
+ Json = GeneratePasteData(text, password, expire, openDiscussion, burnAfterReading, format);
}
catch (Exception ex)
{
throw new Exception("Failed to generate encrypted data, " + ex.Message);
}
- string body = Newtonsoft.Json.JsonConvert.SerializeObject(Json.Item1);
+ string body = Newtonsoft.Json.JsonConvert.SerializeObject(Json.Item1);
HttpRequestMessage Req = new HttpRequestMessage(HttpMethod.Post, HostURL)
{
Content = new StringContent(body, Encoding.UTF8)
@@ -146,7 +152,12 @@ public async Task CreatePaste(string text, string password, string expire
};
}
- private static Tuple GeneratePasteData(string text, string password, string expire, bool openDiscussion, bool burnAfterReading)
+ private static Tuple GeneratePasteData(string text,
+ string password,
+ string expire,
+ bool openDiscussion,
+ bool burnAfterReading,
+ string format)
{
SecureRandom rng = new();
@@ -178,8 +189,11 @@ private static Tuple GeneratePasteData(string text, string pa
string compressionType = "none";
int _openDiscussion = openDiscussion ? 1 : 0;
int _burnAfterReading = burnAfterReading ? 1 : 0;
+ byte[] _format = Array.Empty();
+ if (!string.IsNullOrEmpty(format))
+ _format = UTF8Encoding.UTF8.GetBytes(format);
- object[] pasteMetaObj = new object[]
+ object[] pasteMetaObj = new object[]
{
new object[]
{
@@ -192,7 +206,7 @@ private static Tuple GeneratePasteData(string text, string pa
cipherMode,
compressionType
},
- "plaintext",
+ format,
_openDiscussion,
_burnAfterReading
};
diff --git a/PrivateBinSharp/PrivateBinSharp.xml b/PrivateBinSharp/PrivateBinSharp.xml
index 93f0679..78c7540 100644
--- a/PrivateBinSharp/PrivateBinSharp.xml
+++ b/PrivateBinSharp/PrivateBinSharp.xml
@@ -1494,7 +1494,7 @@
Version of the current PrivateBinSharp lib installed.
-
+
Create a paste that will be encrypted
@@ -1503,6 +1503,7 @@
+