diff options
-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(); |