-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathByteUtils.cs
32 lines (26 loc) · 830 Bytes
/
ByteUtils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Collections.Generic;
namespace Padding_Oracle_Attack
{
static class ByteUtils
{
public static List<byte[]> SliceIntoBlocks(byte[] bytes, int blockSizeBytes = 16)
{
var blocks = new List<byte[]>();
for (var i = 0; i < bytes.Length; i += blockSizeBytes)
{
byte[] block = new byte[blockSizeBytes];
Array.Copy(bytes, i, block, 0, blockSizeBytes);
blocks.Add(block);
}
return blocks;
}
public static byte[] Concatenate(byte[] first, byte[] second)
{
var result = new byte[first.Length + second.Length];
first.CopyTo(result, 0);
second.CopyTo(result, first.Length);
return result;
}
}
}