diff options
Diffstat (limited to 'crypto/src/bcpg/sig/SignerUserId.cs')
-rw-r--r-- | crypto/src/bcpg/sig/SignerUserId.cs | 38 |
1 files changed, 7 insertions, 31 deletions
diff --git a/crypto/src/bcpg/sig/SignerUserId.cs b/crypto/src/bcpg/sig/SignerUserId.cs index 6f812e210..bfa00d078 100644 --- a/crypto/src/bcpg/sig/SignerUserId.cs +++ b/crypto/src/bcpg/sig/SignerUserId.cs @@ -1,3 +1,5 @@ +using Org.BouncyCastle.Utilities; + namespace Org.BouncyCastle.Bcpg.Sig { /** @@ -6,44 +8,18 @@ namespace Org.BouncyCastle.Bcpg.Sig public class SignerUserId : SignatureSubpacket { - private static byte[] UserIdToBytes( - string id) - { - byte[] idData = new byte[id.Length]; - - for (int i = 0; i != id.Length; i++) - { - idData[i] = (byte)id[i]; - } - - return idData; - } - - public SignerUserId( - bool critical, - bool isLongLength, - byte[] data) + public SignerUserId(bool critical, bool isLongLength, byte[] data) : base(SignatureSubpacketTag.SignerUserId, critical, isLongLength, data) { } - public SignerUserId( - bool critical, - string userId) - : base(SignatureSubpacketTag.SignerUserId, critical, false, UserIdToBytes(userId)) + public SignerUserId(bool critical, string userId) + : base(SignatureSubpacketTag.SignerUserId, critical, false, Strings.ToUtf8ByteArray(userId)) { } - public string GetId() - { - char[] chars = new char[data.Length]; - - for (int i = 0; i != chars.Length; i++) - { - chars[i] = (char)(data[i] & 0xff); - } + public string GetId() => Strings.FromUtf8ByteArray(data); - return new string(chars); - } + public byte[] GetRawId() => Arrays.Clone(data); } } |