summary refs log tree commit diff
path: root/crypto/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/util')
-rw-r--r--crypto/src/util/io/BinaryReaders.cs9
1 files changed, 9 insertions, 0 deletions
diff --git a/crypto/src/util/io/BinaryReaders.cs b/crypto/src/util/io/BinaryReaders.cs
index c5f99a712..ed4b57d0a 100644
--- a/crypto/src/util/io/BinaryReaders.cs
+++ b/crypto/src/util/io/BinaryReaders.cs
@@ -1,10 +1,19 @@
 using System;
 using System.IO;
+using System.Text;
 
 namespace Org.BouncyCastle.Utilities.IO
 {
     public static class BinaryReaders
     {
+        internal static T Parse<T>(Func<BinaryReader, T> parse, Stream stream, bool leaveOpen)
+        {
+            using (var binaryReader = new BinaryReader(stream, Encoding.UTF8, leaveOpen))
+            {
+                return parse(binaryReader);
+            }
+        }
+
         public static byte[] ReadBytesFully(BinaryReader binaryReader, int count)
         {
             byte[] bytes = binaryReader.ReadBytes(count);