DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Feb 2008
    Posts
    102

    C program for Ceaser Cipher method

    can anyone send me C program for Caesar Cipher model?


    Thanks a lot in advance

  2. #2
    Join Date
    Dec 2003
    Posts
    3,366
    read the policy on homework and such.

    This one is ultra simple, however, so I will get you started. The Caesar Cipher just shifts the same amount each time. Like, A becomes B, B becomes C, etc. if you shifted by 1 each time. Meanwhile the modulus operator, %, you should understand what this operator does, it will help.

    so all you really need is to iterate over each character and shift it with a modulo.

    For example:
    shift = 3;
    for(x = 0; x < all_the_characters; x++)
    astring[x] = (astring[x]+shift) % 256; ///this one just wraps the ascii table. You can also use % to wrap within the printable characters if you prefer it.

    Note that this is very, very poor encryption: a 10 year old can break the code in about 30 seconds. Consider something at least moderately difficult to solve, such as xor each byte with a random number from a known random number sequence.
    Last edited by jonnin; 02-25-2011 at 10:19 AM.

  3. #3
    Join Date
    Feb 2008
    Posts
    102

    How to include space in Ceaser Cipher

    Now I made Ceaser Cipher program for input DEVX
    but my program do not run if input is DEVX FORUM, how to include space in ceaser cipher

    Thanks a lot in advance for ur replies

Similar Threads

  1. help, dont know why program is too slow
    By bob2000 in forum Java
    Replies: 1
    Last Post: 02-18-2007, 07:43 PM
  2. Help with Server program
    By sedricbenson@ho in forum C++
    Replies: 2
    Last Post: 11-07-2006, 08:18 AM
  3. Connecting to a Server Program HELP
    By sedricbenson@ho in forum C++
    Replies: 2
    Last Post: 11-07-2006, 07:58 AM
  4. problem in program in c++
    By mheasen in forum Architecture and Design
    Replies: 0
    Last Post: 03-20-2002, 09:24 AM
  5. depricated method needs changing
    By Alan Shiers in forum Java
    Replies: 0
    Last Post: 03-15-2002, 12:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links