diff options
Diffstat (limited to 'crypto/src/util')
-rw-r--r-- | crypto/src/util/Strings.cs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crypto/src/util/Strings.cs b/crypto/src/util/Strings.cs index b1a63a3a1..147b6d349 100644 --- a/crypto/src/util/Strings.cs +++ b/crypto/src/util/Strings.cs @@ -18,12 +18,22 @@ namespace Org.BouncyCastle.Utilities public static string FromByteArray(byte[] bs) { +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + return string.Create(bs.Length, bs, (chars, bytes) => + { + for (int i = 0; i < chars.Length; ++i) + { + chars[i] = Convert.ToChar(bytes[i]); + } + }); +#else char[] cs = new char[bs.Length]; for (int i = 0; i < cs.Length; ++i) { cs[i] = Convert.ToChar(bs[i]); } return new string(cs); +#endif } public static byte[] ToByteArray(char[] cs) |