Exemplo n.º 1
0
        public void xxHashTestComputeHashOffsetZero()
        {
            xxHash target = new Martin.SQLServer.Dts.xxHash();

            byte[] buffer   = ASCIIEncoding.ASCII.GetBytes("ThisIsATestValueForxxHash64");
            byte[] expected = GetStringToBytes("f8d1c99eda0d8577");  // https://asecuritysite.com/encryption/xxHash  BUT, reverse the hash bytes.
            byte[] actual;
            actual = target.ComputeHash(buffer, 0, buffer.Length);
            Assert.AreEqual(expected.Length, actual.Length);
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Populates the OutputColumn class with all the required information to generate Hash's.
        /// </summary>
        /// <param name="bufferManager">The buffermanager that is affected by this</param>
        /// <param name="output">The output to find the column in</param>
        /// <param name="input">The input where all the data comes from</param>
        /// <param name="outputColumnIndex">The Column Index of the output column.</param>
        public void AddColumnInformation(IDTSBufferManager bufferManager, IDTSOutput output, IDTSInput input, int outputColumnIndex)
        {
            if (bufferManager == null)
            {
                throw new ArgumentNullException("bufferManager");
            }

            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (output == null)
            {
                throw new ArgumentNullException("output");
            }

            IDTSOutputColumn outputColumn = output.OutputColumnCollection[outputColumnIndex];

            string[] inputLineageIDList;
            inputLineageIDList  = outputColumn.CustomPropertyCollection[Utility.InputColumnLineagePropName].Value.ToString().Split(',');
            this.outputHashType = (MultipleHash.HashTypeEnumerator)outputColumn.CustomPropertyCollection[Utility.HashTypePropName].Value;
            this.outputDataType = (MultipleHash.OutputTypeEnumerator)outputColumn.CustomPropertyCollection[Utility.OutputColumnOutputTypePropName].Value;

            switch (this.outputHashType)
            {
            case MultipleHash.HashTypeEnumerator.None:
                break;

            case MultipleHash.HashTypeEnumerator.MD5:
                this.hashMD5 = MD5.Create();
                break;

            case MultipleHash.HashTypeEnumerator.RipeMD160:
                this.hashRipeMD160 = RIPEMD160.Create();
                break;

            case MultipleHash.HashTypeEnumerator.SHA1:
                this.hashSHA1 = SHA1.Create();
                break;

            case MultipleHash.HashTypeEnumerator.SHA256:
                this.hashSHA256 = SHA256.Create();
                break;

            case MultipleHash.HashTypeEnumerator.SHA384:
                this.hashSHA384 = SHA384.Create();
                break;

            case MultipleHash.HashTypeEnumerator.SHA512:
                this.hashSHA512 = SHA512.Create();
                break;

            case MultipleHash.HashTypeEnumerator.CRC32:
                this.hashCRC32 = CRC32.Create();
                break;

            case MultipleHash.HashTypeEnumerator.CRC32C:
                this.hashCRC32C = CRC32C.Create();
                break;

            case MultipleHash.HashTypeEnumerator.FNV1a32:
                this.hashFNV1a32 = FNV1a32.Create();
                break;

            case MultipleHash.HashTypeEnumerator.FNV1a64:
                this.hashFNV1a64 = FNV1a64.Create();
                break;

            case MultipleHash.HashTypeEnumerator.MurmurHash3a:
                //ToDo: Call the MurmurHash
                this.hashMurmur3a = Murmur3a.Create();
                break;

            case MultipleHash.HashTypeEnumerator.xxHash:
                // todo: call the xxHash
                this.hashxxHash = xxHash.Create();
                break;

            default:
                break;
            }

            // Store all the input column ID's for the column's to be Hashed
            int inputColumnLineageID;

            foreach (string inputLineageID in inputLineageIDList)
            {
                int columnId = System.Convert.ToInt32(inputLineageID.Substring(1));
                Microsoft.SqlServer.Dts.Pipeline.Wrapper.DTP_BUFFCOL columnData = new Microsoft.SqlServer.Dts.Pipeline.Wrapper.DTP_BUFFCOL();
                inputColumnLineageID = bufferManager.FindColumnByLineageID(input.Buffer, columnId);  // Strip the # from the ID

                bufferManager.GetColumnInfo(input.Buffer, inputColumnLineageID, ref columnData);
                MHashColumnInformation inputColumn = new MHashColumnInformation(inputColumnLineageID, columnData.DataType);
                this.inputColumnDetails.Add(inputColumn);
            }

            // Store the Column ID for the Output Column
            this.outputColumnID = bufferManager.FindColumnByLineageID(input.Buffer, outputColumn.LineageID);
        }
Exemplo n.º 3
0
        public void InitialiseTest()
        {
            xxHash actual = new Martin.SQLServer.Dts.xxHash();

            actual.Initialize();
        }