/********EXTERNAL OBJECT PUBLIC METHODS - END ********/ private string CalculateCRC(byte[] input, ChecksumAlgorithm checksumAlgorithm) { CRCParameters parms = ChecksumAlgorithmUtils.getParameters(checksumAlgorithm, this.error); if (this.HasError()) { return(""); } long aux = CalculateCRC(input, parms); if (aux == 0 || this.HasError()) { return(""); } switch (parms.Width) { case 8: return(aux.ToString("X2")); case 16: return(aux.ToString("X4")); case 32: return(aux.ToString("X8")); default: return(aux.ToString("X")); } }
public string GenerateChecksum(string input, string inputType, string checksumAlgorithm) { ChecksumInputType chksumInputType = ChecksumInputTypeUtils.getChecksumInputType(inputType, this.error); byte[] inputBytes = ChecksumInputTypeUtils.getBytes(chksumInputType, input, this.error); if (this.HasError()) { return(""); } ChecksumAlgorithm algorithm = ChecksumAlgorithmUtils.getChecksumAlgorithm(checksumAlgorithm, this.error); if (this.HasError()) { return(""); } return((ChecksumAlgorithmUtils.isHash(algorithm)) ? CalculateHash(inputBytes, algorithm) : CalculateCRC(inputBytes, algorithm)); }
private HashUtils.HashAlgorithm getHashAlgorithm(ChecksumAlgorithm checksumAlgorithm) { return(HashAlgorithmUtils.getHashAlgorithm(ChecksumAlgorithmUtils.valueOf(checksumAlgorithm, this.error), this.error)); }