AlgoParams.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package com.its.app.utils.crc;
  2. /**
  3. * Created by anthony on 11.05.2017.
  4. */
  5. public class AlgoParams
  6. {
  7. public AlgoParams(String name, int hashSize, long poly, long init, boolean refIn, boolean refOut, long xorOut, long check)
  8. {
  9. Name = name;
  10. Check = check;
  11. Init = init;
  12. Poly = poly;
  13. RefIn = refIn;
  14. RefOut = refOut;
  15. XorOut = xorOut;
  16. HashSize = hashSize;
  17. }
  18. /// <summary>
  19. /// This field is not strictly part of the definition, and, in
  20. /// the event of an inconsistency between this field and the other
  21. /// field, the other fields take precedence.This field is a check
  22. /// value that can be used as a weak validator of implementations of
  23. /// the algorithm.The field contains the checksum obtained when the
  24. /// ASCII string "123456789" is fed through the specified algorithm
  25. /// (i.e. 313233... (hexadecimal)).
  26. /// </summary>
  27. public long Check;
  28. /// <summary>
  29. /// This is hash size.
  30. /// </summary>
  31. public int HashSize;
  32. /// <summary>
  33. /// This parameter specifies the initial value of the register
  34. /// when the algorithm starts.This is the value that is to be assigned
  35. /// to the register in the direct table algorithm. In the table
  36. /// algorithm, we may think of the register always commencing with the
  37. /// value zero, and this value being XORed into the register after the
  38. /// N'th bit iteration. This parameter should be specified as a
  39. /// hexadecimal number.
  40. /// </summary>
  41. public long Init;
  42. /// <summary>
  43. /// This is a name given to the algorithm. A string value.
  44. /// </summary>
  45. public String Name;
  46. /// <summary>
  47. /// This parameter is the poly. This is a binary value that
  48. /// should be specified as a hexadecimal number.The top bit of the
  49. /// poly should be omitted.For example, if the poly is 10110, you
  50. /// should specify 06. An important aspect of this parameter is that it
  51. /// represents the unreflected poly; the bottom bit of this parameter
  52. /// is always the LSB of the divisor during the division regardless of
  53. /// whether the algorithm being modelled is reflected.
  54. /// </summary>
  55. public long Poly;
  56. /// <summary>
  57. /// This is a boolean parameter. If it is FALSE, input bytes are
  58. /// processed with bit 7 being treated as the most significant bit
  59. /// (MSB) and bit 0 being treated as the least significant bit.If this
  60. /// parameter is FALSE, each byte is reflected before being processed.
  61. /// </summary>
  62. public boolean RefIn;
  63. /// <summary>
  64. /// This is a boolean parameter. If it is set to FALSE, the
  65. /// final value in the register is fed into the XOROUT stage directly,
  66. /// otherwise, if this parameter is TRUE, the final register value is
  67. /// reflected first.
  68. /// </summary>
  69. public boolean RefOut;
  70. /// <summary>
  71. /// This is an W-bit value that should be specified as a
  72. /// hexadecimal number.It is XORed to the final register value (after
  73. /// the REFOUT) stage before the value is returned as the official
  74. /// checksum.
  75. /// </summary>
  76. public long XorOut;
  77. }