当前位置: 首页>>代码示例>>C#>>正文


C# UInt64.GetBit方法代码示例

本文整理汇总了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;
 }
开发者ID:Kant8,项目名称:ISM,代码行数:11,代码来源:BlockHelper.cs

示例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;
        }
开发者ID:Kant8,项目名称:ISM,代码行数:36,代码来源:DES.cs

示例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;
 }
开发者ID:Kant8,项目名称:ISM,代码行数:10,代码来源:DES.cs


注:本文中的System.UInt64.GetBit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。