summaryrefslogtreecommitdiff
path: root/Util.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Util.cs')
-rw-r--r--Util.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/Util.cs b/Util.cs
new file mode 100644
index 0000000..9f261ee
--- /dev/null
+++ b/Util.cs
@@ -0,0 +1,17 @@
+using System.Runtime.InteropServices;
+using System.Security;
+
+namespace HyperBooru.PowerShell;
+
+internal static class Util {
+ internal static string ToInsecureString(this SecureString x) {
+ IntPtr rawString = IntPtr.Zero;
+ try {
+ rawString = Marshal.SecureStringToBSTR(x);
+ return Marshal.PtrToStringBSTR(rawString);
+ } finally {
+ if(rawString != IntPtr.Zero)
+ Marshal.FreeBSTR(rawString);
+ }
+ }
+}