当前位置: 首页>>代码示例>>C#>>正文


C# IBigInteger.ToByteArrayUnsigned方法代码示例

本文整理汇总了C#中IBigInteger.ToByteArrayUnsigned方法的典型用法代码示例。如果您正苦于以下问题:C# IBigInteger.ToByteArrayUnsigned方法的具体用法?C# IBigInteger.ToByteArrayUnsigned怎么用?C# IBigInteger.ToByteArrayUnsigned使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IBigInteger的用法示例。


在下文中一共展示了IBigInteger.ToByteArrayUnsigned方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

        /// <summary>
        /// Creates a ECDH public key parameters from the given encoded point.
        /// </summary>
        /// <param name="encodedPoint">The encoded point.</param>
        /// <param name="publicKeyParamSet">The public key param set.</param>
        /// <param name="hashAlgorithm">The hash algorithm.</param>
        /// <param name="symmetricKeyAlgorithm">The symmetric key algorithm.</param>
        /// <returns></returns>
        public static ECDHPublicKeyParameters Create(IBigInteger encodedPoint, DerObjectIdentifier publicKeyParamSet, 
            HashAlgorithmTag hashAlgorithm, SymmetricKeyAlgorithmTag symmetricKeyAlgorithm)
        {
            var curve = ECKeyPairGenerator.FindECCurveByOid(publicKeyParamSet);
            var point = curve.Curve.DecodePoint(encodedPoint.ToByteArrayUnsigned());

            return new ECDHPublicKeyParameters(point, publicKeyParamSet, hashAlgorithm, symmetricKeyAlgorithm);
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:16,代码来源:ECDHPublicKeyParameters.cs

示例2: ECPrivateKeyStructure

        public ECPrivateKeyStructure(
			IBigInteger key)
        {
            if (key == null)
                throw new ArgumentNullException("key");

            this.seq = new DerSequence(
                new DerInteger(1),
                new DerOctetString(key.ToByteArrayUnsigned()));
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:10,代码来源:ECPrivateKeyStructure.cs

示例3: ConvertOutput

        public byte[] ConvertOutput(
			IBigInteger result)
        {
            byte[] output = result.ToByteArrayUnsigned();

            if (forEncryption)
            {
                int outSize = GetOutputBlockSize();

                // TODO To avoid this, create version of BigInteger.ToByteArray that
                // writes to an existing array
                if (output.Length < outSize) // have ended up with less bytes than normal, lengthen
                {
                    byte[] tmp = new byte[outSize];
                    output.CopyTo(tmp, tmp.Length - output.Length);
                    output = tmp;
                }
            }

            return output;
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:21,代码来源:RSACoreEngine.cs

示例4: IntegerToBytes

        public static byte[] IntegerToBytes(
            IBigInteger s,
			int			qLength)
        {
            byte[] bytes = s.ToByteArrayUnsigned();

            if (qLength < bytes.Length)
            {
                byte[] tmp = new byte[qLength];
                Array.Copy(bytes, bytes.Length - tmp.Length, tmp, 0, tmp.Length);
                return tmp;
            }
            if (qLength > bytes.Length)
            {
                byte[] tmp = new byte[qLength];
                Array.Copy(bytes, 0, tmp, tmp.Length - bytes.Length, bytes.Length);
                return tmp;
            }

            return bytes;
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:21,代码来源:X9IntegerConverter.cs

示例5: IntArray

        public IntArray(IBigInteger bigInt, int minIntLen)
        {
            if (bigInt.SignValue == -1)
                throw new ArgumentException(@"Only positive Integers allowed", "bigInt");

            if (bigInt.SignValue == 0)
            {
                _ints = new int[] { 0 };
                return;
            }

            var barr = bigInt.ToByteArrayUnsigned();
            var barrLen = barr.Length;

            var intLen = (barrLen + 3) / 4;
            _ints = new int[System.Math.Max(intLen, minIntLen)];

            var rem = barrLen % 4;
            var barrI = 0;

            if (0 < rem)
            {
                var temp = (int) barr[barrI++];
                while (barrI < rem)
                {
                    temp = temp << 8 | (int) barr[barrI++];
                }
                _ints[--intLen] = temp;
            }

            while (intLen > 0)
            {
                var temp = (int) barr[barrI++];
                for (var i = 1; i < 4; i++)
                {
                    temp = temp << 8 | (int) barr[barrI++];
                }
                _ints[--intLen] = temp;
            }
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:40,代码来源:IntArray.cs

示例6: AsUnsignedByteArray

        /**
        * Return the passed in value as an unsigned byte array.
        *
        * @param value value to be converted.
        * @return a byte array without a leading zero byte if present in the signed encoding.
        */
        public static byte[] AsUnsignedByteArray(
			IBigInteger n)
        {
            return n.ToByteArrayUnsigned();
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:11,代码来源:BigIntegers.cs

示例7: EncodeInteger

 internal static void EncodeInteger(IBcpgOutputStream bcpgOut, IBigInteger val)
 {
     bcpgOut.WriteShort((short)val.BitLength);
     bcpgOut.Write(val.ToByteArrayUnsigned());
 }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:5,代码来源:MPInteger.cs

示例8: DecodePoint

        private static ECPoint DecodePoint(IBigInteger encodedPoint, DerObjectIdentifier oid)
        {
            var curve = ECKeyPairGenerator.FindECCurveByOid(oid);
            if (curve == null)
                throw new PgpException(oid.Id + " does not match any known curve.");
            if (!(curve.Curve is FPCurve))
                throw new PgpException("Only FPCurves are supported.");

            return curve.Curve.DecodePoint(encodedPoint.ToByteArrayUnsigned());
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:10,代码来源:EcPublicBcpgKey.cs


注:本文中的IBigInteger.ToByteArrayUnsigned方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。