本文整理匯總了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;
}