Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 10th, 2003, 09:31 AM
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Bit Operation in C#?

Can i make operation in bit level by using C#?
I want to implement DES Cipher in CBC mode.
 
Old August 15th, 2003, 03:51 AM
Authorized User
 
Join Date: Aug 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Should be possible, depends exactly what you want to do but I've
done bitwise ops for implementing security algorithms.

Sample code below:

static public int OneByteValToByteStream(ref byte[] byteArr, int nStartIndex, byte byteVal)
{
    for(int i=0; i<1; i++)
        byteArr[nStartIndex++] = (byte)((byteVal>>(i*8))&0x00FF);
    return nStartIndex;
}

    for (j=0; j<2; j++)
    {
      x0 >>=1; if (x1 & 0x1) x0 |= 0x80;
      x1 >>=1; if (x2 & 0x1) x1 |= 0x80;
      x2 >>=1; if (x3 & 0x1) x2 |= 0x80;
      x3 >>=1; if (x4 & 0x1) x3 |= 0x80;
      x4 >>=1; if (carry & 1) x4 |= 0x80;

      carry >>=1;
    }







Similar Threads
Thread Thread Starter Forum Replies Last Post
Bit of Application Sunilmesu Visual Basic 2005 Basics 1 March 26th, 2008 09:35 AM
64 bit p0120144 BOOK: Professional Assembly Language 1 December 26th, 2006 10:04 PM
64 Bit - Issue in 64 bit IIS calling Win32 API Hubman General .NET 1 August 24th, 2006 09:19 AM
A bit concerned JoanW BOOK: Accessible XHTML and CSS Web Sites: Problem Design Solution 1 April 24th, 2006 08:24 AM
bit error! sxbluebird BOOK: Professional C#, 2nd and 3rd Editions 0 February 10th, 2004 06:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.