コード例 #1
0
ファイル: DES.cs プロジェクト: gaojunxuan/GranadosRT
        public void EncryptCBC([ReadOnlyArray()] byte[] input, int inputOffset, int inputLen, [WriteOnlyArray()] byte[] output, int outputOffset)
        {
            int nBlocks = inputLen / 8;

            for (int bc = 0; bc < nBlocks; bc++)
            {
                CipherUtil.BlockXor(input, inputOffset, 8, _iv, 0);
                BlockEncrypt(_iv, 0, output, outputOffset);
                Array.Copy(output, outputOffset, _iv, 0, 8);
                inputOffset  += 8;
                outputOffset += 8;
            }
        }
コード例 #2
0
ファイル: Blowfish.cs プロジェクト: gaojunxuan/GranadosRT
        public void encryptCBC([ReadOnlyArray()] byte[] input, int inputOffset, int inputLen, [WriteOnlyArray()] byte[] output, int outputOffset)
        {
            int nBlocks = inputLen / BLOCK_SIZE;

            for (int bc = 0; bc < nBlocks; bc++)
            {
                CipherUtil.BlockXor(input, inputOffset, BLOCK_SIZE, IV, 0);
                blockEncrypt(IV, 0, output, outputOffset);
                Array.Copy(output, outputOffset, IV, 0, BLOCK_SIZE);
                inputOffset  += BLOCK_SIZE;
                outputOffset += BLOCK_SIZE;
            }
        }
コード例 #3
0
        public void encryptCBC([ReadOnlyArray()] byte[] input, int inputOffset, int inputLen, [WriteOnlyArray()] byte[] output, int outputOffset)
        {
            int block_size = GetBlockSize();
            int nBlocks    = inputLen / block_size;

            for (int bc = 0; bc < nBlocks; bc++)
            {
                CipherUtil.BlockXor(input, inputOffset, block_size, _IV, 0);
                blockEncrypt(_IV, 0, output, outputOffset);
                Array.Copy(output, outputOffset, _IV, 0, block_size);
                inputOffset  += block_size;
                outputOffset += block_size;
            }
        }
コード例 #4
0
        public void encryptCTR([ReadOnlyArray()] byte[] input, int inputOffset, int inputLen, [WriteOnlyArray()] byte[] output, int outputOffset)
        {
            int block_size = GetBlockSize();
            int nBlocks    = inputLen / block_size;

            byte[] tmpBlk = new byte[block_size];
            for (int bc = 0; bc < nBlocks; bc++)
            {
                blockEncrypt(_IV, 0, tmpBlk, 0);
                CipherUtil.BlockXor(input, inputOffset, block_size, tmpBlk, 0);
                Array.Copy(tmpBlk, 0, output, outputOffset, block_size);
                incrementIV();
                inputOffset  += block_size;
                outputOffset += block_size;
            }
        }