/// <summary>对指定的对象标识符 (OID) 进行编码。</summary> /// <returns>包含编码 OID 的字节数组。</returns> /// <param name="str">要进行编码的 OID。</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="str" /> 参数为 null。</exception> /// <exception cref="T:System.Security.Cryptography.CryptographicUnexpectedOperationException">对 OID 进行编码时出现错误。</exception> public static byte[] EncodeOID(string str) { if (str == null) throw new ArgumentNullException("str"); char[] chArray = new char[1]{ '.' }; string[] strArray = str.Split(chArray); uint[] numArray1 = new uint[strArray.Length]; for (int index = 0; index < strArray.Length; ++index) numArray1[index] = (uint) int.Parse(strArray[index], (IFormatProvider) CultureInfo.InvariantCulture); byte[] numArray2 = new byte[numArray1.Length * 5]; int destinationIndex = 0; if (numArray1.Length < 2) throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_InvalidOID")); byte[] numArray3 = CryptoConfig.EncodeSingleOIDNum(numArray1[0] * 40U + numArray1[1]); Array.Copy((Array) numArray3, 0, (Array) numArray2, destinationIndex, numArray3.Length); int num = destinationIndex + numArray3.Length; for (int index = 2; index < numArray1.Length; ++index) { byte[] numArray4 = CryptoConfig.EncodeSingleOIDNum(numArray1[index]); Buffer.InternalBlockCopy((Array) numArray4, 0, (Array) numArray2, num, numArray4.Length); num += numArray4.Length; } if (num > (int) sbyte.MaxValue) throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_Config_EncodedOIDError")); byte[] numArray5 = new byte[num + 2]; numArray5[0] = (byte) 6; numArray5[1] = (byte) num; Buffer.InternalBlockCopy((Array) numArray2, 0, (Array) numArray5, 2, num); return numArray5; }