Thread: Quick quester

  1. #1
    Registered User
    Join Date
    Apr 2004

    Quick quester

    Hey, how would you assess the dificulty in writing an bitwiseshift decryption program is C++? Moderate? Easy? Difficult? It would have to decrypt at a specified shift place (like three left).

    Also, is it possible to write one in any type of scripting language (aka javascript)?


  2. #2
    Registered User
    Join Date
    Nov 2001
    Definitely. One you get the algorithm down mathematically, the coding is simple.


  3. #3
    Hardware Engineer
    Join Date
    Sep 2001

    It's not hard if you know a couple of things...

    You need to know about file I/O, and bit-shifting. There is some good information about bit shifting in the Programming FAQ.

    Something keep in-mind: Bit-shifting throws-away bits. If you shift-left 3 bits, you loose the 3 leftmost bits. This should NOT be a problem with most 16-bit or 32 bit operating systems, assuming that you are encrypting/decrypting ASCII, which only uses 8-bits. You may need to use typecasting or some other tricks to get your data into a type with enough extra bits. Good programming practice would require you to use sizeof() or <limits> to make sure that you never loose any data.

    If you want to do bit-rotation, and put those "lost" leftmost bits into the "new" rightmost bits, you'll have to write the code yourself using the other bitwise operators.

    I don't know java script, but I sort-of suspect it's too "high-level" to have any bit manipulation instructions. You could do bit-shifting by multiplying and dividing by two (or multiples of two).
    Last edited by DougDbug; 06-02-2004 at 12:34 PM.

  4. #4
    Registered User
    Join Date
    Apr 2004
    Okay, thanks. That's really helpful. I need to write one to decrypt a file from a challenge site and I think it's a bitwise shift, or rotation. IE: 100110 shifted 2 left would be 011010. I appriciate the help though I think that I'll need some specific questions answered when I get down to coding it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 07:48 PM
  2. Do you know...
    By davejigsaw in forum C++ Programming
    Replies: 1
    Last Post: 05-10-2005, 10:33 AM
  3. Questions on basic Quick Sort
    By Weng in forum C++ Programming
    Replies: 4
    Last Post: 12-16-2003, 10:06 AM
  4. Quick Sort Help
    By NavyBlue in forum C Programming
    Replies: 1
    Last Post: 03-02-2003, 10:34 PM
  5. Replies: 0
    Last Post: 04-30-2002, 07:24 PM