本文整理汇总了C#中Slice.ToSlice方法的典型用法代码示例。如果您正苦于以下问题:C# Slice.ToSlice方法的具体用法?C# Slice.ToSlice怎么用?C# Slice.ToSlice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slice
的用法示例。
在下文中一共展示了Slice.ToSlice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessSymmetricCrypt
private static void ProcessSymmetricCrypt(Slice<byte> cryptProcessingBuffer, Slice<byte> target, Slice<byte> blocks, byte length, bool encrypt)
{
if ((length % 8) != 0)
throw new ArgumentOutOfRangeException(nameof(length), "Length must be a multiple of 8");
var temp = new byte[8];
var blockCount = length / 8;
for (var index = 0; index != blockCount; ++index)
{
CopyReverse4X2(temp.ToSlice(), blocks.ToSlice(index * 8, 0x08));
uint itemLo, itemHi;
var isDecryption = !encrypt;
if (isDecryption)
{
itemLo = BitConverter.ToUInt32(temp, 0);
itemHi = BitConverter.ToUInt32(temp, 4);
}
else
{
itemLo = BitConverter.ToUInt32(temp, 0);
var tempLo = BitConverter.ToUInt32(cryptProcessingBuffer.ToArray(0x80, 4), 0);
itemLo ^= tempLo;
itemHi = BitConverter.ToUInt32(temp, 4);
var tempHi = BitConverter.ToUInt32(cryptProcessingBuffer.ToArray(0x84, 4), 0);
itemHi ^= tempHi;
}
PerformCrypt(cryptProcessingBuffer.ToArray(), ref itemLo, ref itemHi);
if (isDecryption)
{
var tempLo = BitConverter.ToUInt32(cryptProcessingBuffer.ToArray(0x80, 4), 0);
var tempHi = BitConverter.ToUInt32(cryptProcessingBuffer.ToArray(0x84, 4), 0);
itemLo ^= tempLo;
itemHi ^= tempHi;
cryptProcessingBuffer.ToSlice(0x80, 8).CopyFrom(temp);
}
else
{
cryptProcessingBuffer.ToSlice(0x80, 4).CopyFrom(BitConverter.GetBytes(itemLo));
cryptProcessingBuffer.ToSlice(0x84, 4).CopyFrom(BitConverter.GetBytes(itemHi));
}
WriteToBigEndian32(target.ToSlice(index * 8, 8), itemLo, itemHi);
}
}
示例2: BuildCryptKey
private static void BuildCryptKey(Slice<byte> cryptProcessingBuffer, Slice<byte> keyChars, Slice<byte> inputIndexes, bool encrypt)
{
CopyReverse4X2(cryptProcessingBuffer.ToSlice(0x80, 0x08), inputIndexes);
CopyReverse4X2(cryptProcessingBuffer.ToSlice(0x88, 0x08), inputIndexes);
BuildCryptKey(cryptProcessingBuffer, keyChars, encrypt);
}