Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CrcHashAlgorithm{TTable}"/> class.
        /// </summary>
        /// <param name="type">The type.</param>
        public CrcHashAlgorithm(CRCTypes type)
        {
            FieldInfo            fi = type.GetType().GetField(type.ToString());
            DescriptionAttribute m  = fi.GetCustomAttributes(typeof(DescriptionAttribute), false).Single() as DescriptionAttribute;

            if (m == null)
            {
                throw new ArgumentNullException("Not exist description attribute.");
            }

            CrcName = m.Description;

            if (!Paramters.ContainsKey(CrcName))
            {
                throw new ArgumentException();
            }

            Paramter = Paramters[CrcName];
            CrcType  = type;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Generates the specified paramter.
 /// </summary>
 /// <param name="paramter">The paramter.</param>
 /// <returns></returns>
 internal override uint[] Generate(CrcParamter <uint> paramter) => CrcHashAlgorithmHelper.GenerateTable(paramter.Polynomial, paramter.Width, paramter.RefInput, Mask);
Exemplo n.º 3
0
 /// <summary>
 /// Generates the specified paramter.
 /// </summary>
 /// <param name="paramter">The paramter.</param>
 /// <returns></returns>
 internal abstract TTable[] Generate(CrcParamter <TTable> paramter);