Pack.cs :  » PDF » iTextSharp » Org » BouncyCastle » Crypto » Utilities » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » PDF » iTextSharp 
iTextSharp » Org » BouncyCastle » Crypto » Utilities » Pack.cs
using System;

namespace Org.BouncyCastle.Crypto.Utilities{
  internal sealed class Pack
  {
    private Pack()
    {
    }

    internal static void UInt32_To_BE(uint n, byte[] bs)
    {
      bs[0] = (byte)(n >> 24);
      bs[1] = (byte)(n >> 16);
      bs[2] = (byte)(n >>  8);
      bs[3] = (byte)(n      );
    }

    internal static void UInt32_To_BE(uint n, byte[] bs, int off)
    {
      bs[  off] = (byte)(n >> 24);
      bs[++off] = (byte)(n >> 16);
      bs[++off] = (byte)(n >>  8);
      bs[++off] = (byte)(n      );
    }

    internal static uint BE_To_UInt32(byte[] bs)
    {
      uint n = (uint)bs[0] << 24;
      n |= (uint)bs[1] << 16;
      n |= (uint)bs[2] << 8;
      n |= (uint)bs[3];
      return n;
    }

    internal static uint BE_To_UInt32(byte[] bs, int off)
    {
      uint n = (uint)bs[off] << 24;
      n |= (uint)bs[++off] << 16;
      n |= (uint)bs[++off] << 8;
      n |= (uint)bs[++off];
      return n;
    }

    internal static ulong BE_To_UInt64(byte[] bs)
      {
          uint hi = BE_To_UInt32(bs);
          uint lo = BE_To_UInt32(bs, 4);
          return ((ulong)hi << 32) | (ulong)lo;
      }

    internal static ulong BE_To_UInt64(byte[] bs, int off)
      {
          uint hi = BE_To_UInt32(bs, off);
          uint lo = BE_To_UInt32(bs, off + 4);
          return ((ulong)hi << 32) | (ulong)lo;
      }

      internal static void UInt64_To_BE(ulong n, byte[] bs)
      {
          UInt32_To_BE((uint)(n >> 32), bs);
          UInt32_To_BE((uint)(n      ), bs, 4);
      }

      internal static void UInt64_To_BE(ulong n, byte[] bs, int off)
      {
          UInt32_To_BE((uint)(n >> 32), bs, off);
          UInt32_To_BE((uint)(n      ), bs, off + 4);
      }

    internal static void UInt32_To_LE(uint n, byte[] bs)
    {
      bs[0] = (byte)(n      );
      bs[1] = (byte)(n >>  8);
      bs[2] = (byte)(n >> 16);
      bs[3] = (byte)(n >> 24);
    }

    internal static void UInt32_To_LE(uint n, byte[] bs, int off)
    {
      bs[  off] = (byte)(n      );
      bs[++off] = (byte)(n >>  8);
      bs[++off] = (byte)(n >> 16);
      bs[++off] = (byte)(n >> 24);
    }

    internal static uint LE_To_UInt32(byte[] bs)
    {
      uint n = (uint)bs[0];
      n |= (uint)bs[1] << 8;
      n |= (uint)bs[2] << 16;
      n |= (uint)bs[3] << 24;
      return n;
    }

    internal static uint LE_To_UInt32(byte[] bs, int off)
    {
      uint n = (uint)bs[off];
      n |= (uint)bs[++off] << 8;
      n |= (uint)bs[++off] << 16;
      n |= (uint)bs[++off] << 24;
      return n;
    }

    internal static ulong LE_To_UInt64(byte[] bs)
      {
          uint lo = LE_To_UInt32(bs);
          uint hi = LE_To_UInt32(bs, 4);
          return ((ulong)hi << 32) | (ulong)lo;
      }

    internal static ulong LE_To_UInt64(byte[] bs, int off)
      {
          uint lo = LE_To_UInt32(bs, off);
          uint hi = LE_To_UInt32(bs, off + 4);
          return ((ulong)hi << 32) | (ulong)lo;
      }

      internal static void UInt64_To_LE(ulong n, byte[] bs)
      {
          UInt32_To_LE((uint)(n      ), bs);
          UInt32_To_LE((uint)(n >> 32), bs, 4);
      }

      internal static void UInt64_To_LE(ulong n, byte[] bs, int off)
      {
          UInt32_To_LE((uint)(n      ), bs, off);
          UInt32_To_LE((uint)(n >> 32), bs, off + 4);
      }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.