本文整理汇总了C#中System.UInt64.GetBit方法的典型用法代码示例。如果您正苦于以下问题:C# UInt64.GetBit方法的具体用法?C# UInt64.GetBit怎么用?C# UInt64.GetBit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.UInt64
的用法示例。
在下文中一共展示了UInt64.GetBit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PermutateBlock
public static UInt64 PermutateBlock(UInt64 block, byte[] table,
bool startFrom0 = true)
{
UInt64 resultBlock = 0;
for (int i = 0; i < table.Length; i++)
{
var bit = block.GetBit(startFrom0 ? table[i] : table[i] - 1);
BitHelper.SetBit(ref resultBlock, i, bit);
}
return resultBlock;
}
示例2: Substitution
private UInt32 Substitution(UInt64 block)
{
UInt32 result = 0;
const int subBlockResultSize = 4;
const int subBlockSize = 6;
const int subBlocksCount = 8;
for (var subBlockIndex = 0; subBlockIndex < subBlocksCount; subBlockIndex++)
{
Byte subBlock = 0;
for (int i = 0; i < subBlockSize; i++)
{
var bit = block.GetBit(subBlockIndex*subBlockSize + i);
BitHelper.SetBit(ref subBlock, i, bit);
}
byte sRowIndex = 0;
BitHelper.SetBit(ref sRowIndex, 0, subBlock.GetBit(0));
BitHelper.SetBit(ref sRowIndex, 1, subBlock.GetBit(5));
byte sColIndex = 0;
for (int i = 0; i < subBlockResultSize; i++)
{
BitHelper.SetBit(ref sColIndex, i, subBlock.GetBit(i+1));
}
var sRes = SBlocks[subBlocksCount - subBlockIndex - 1][sRowIndex, sColIndex];
for (int i = 0; i < subBlockResultSize; i++)
{
var bit = sRes.GetBit(i);
BitHelper.SetBit(ref result, subBlockIndex * subBlockResultSize + i, bit);
}
}
return result;
}
示例3: InitialPermutation
private UInt64 InitialPermutation(UInt64 block)
{
UInt64 resultBlock = 0;
for (int i = 0; i < IpTable.Length; i++)
{
var bit = block.GetBit(IpTable[i] - 1);
BitHelper.SetBit(ref resultBlock, i, bit);
}
return resultBlock;
}