Beispiel #1
0
        private static uint[] GetWords(byte[] chunk)
        {
            var words = new uint[80];

            for (int i = 0; i < 16; i++)
            {
                words[i] = ConversionHelpers.ToUInt(ByteArrayHelpers.CopyPartOf(chunk, i * 4, 4).Reverse().ToArray());
            }
            for (int i = 16; i < 80; i++)
            {
                words[i] = MiscHelpers.LeftRotate(words[i - 3] ^ words[i - 8] ^ words[i - 14] ^ words[i - 16], 1);
            }
            return(words);
        }
Beispiel #2
0
        /// <summary>
        /// Remove PKCS#7 padding. This changes the array's length.
        /// </summary>
        public static byte[] UnPkcs7(byte[] raw)
        {
            int paddingLength = GetPkcs7Length(raw);

            return(ByteArrayHelpers.CopyPartOf(raw, 0, raw.Length - paddingLength));
        }