diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-11-06 19:01:47 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-11-06 19:01:47 +0700 |
commit | 29952f9e647222c44350dcbee4c39108f3b00256 (patch) | |
tree | 03f5fe86840245f9019ac7df368a560d865234b8 /crypto | |
parent | Support parsing of Asn1ObjectDescriptor (diff) | |
download | BouncyCastle.NET-ed25519-29952f9e647222c44350dcbee4c39108f3b00256.tar.xz |
Refactor GetString
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/src/asn1/DerBitString.cs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/crypto/src/asn1/DerBitString.cs b/crypto/src/asn1/DerBitString.cs index caf5d6f9f..591d4403c 100644 --- a/crypto/src/asn1/DerBitString.cs +++ b/crypto/src/asn1/DerBitString.cs @@ -278,15 +278,16 @@ namespace Org.BouncyCastle.Asn1 public override string GetString() { - StringBuilder buffer = new StringBuilder("#"); - byte[] str = GetDerEncoded(); - for (int i = 0; i != str.Length; i++) + StringBuilder buffer = new StringBuilder(1 + str.Length * 2); + buffer.Append('#'); + + for (int i = 0; i != str.Length; i++) { - uint ubyte = str[i]; - buffer.Append(table[(ubyte >> 4) & 0xf]); - buffer.Append(table[str[i] & 0xf]); + uint u8 = str[i]; + buffer.Append(table[u8 >> 4]); + buffer.Append(table[u8 & 0xF]); } return buffer.ToString(); |