Security
  Home arrow Security arrow Page 2 - A Sequel to Cryptography
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
SECURITY

A Sequel to Cryptography
By: Barzan "Tony" Antal
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2007-07-24

    Table of Contents:
  • A Sequel to Cryptography
  • Using XOR on an Example
  • Breaking XOR Encryption
  • Conclusions

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    A Sequel to Cryptography - Using XOR on an Example


    (Page 2 of 4 )

    Let's XOR our example text file with the password "longpassword123."

    %'pl$=#-m:f49ne%!+#*"<#8(=w%#)#<8<s#>+pbml<(nz#8nf"'!zm@DF +u)!!s)?nP$(*-l+p8anw)>:/l9+p8cnp(+=g*>*ebm1y{5{uw

    Check out the full C program:

    #include <fstream>

    #include <stdio.h>

    #include <string.h>

    using namespace std;

    char srcfile[30], dstfile[30], key[255];

    void main()

    {

       printf("Source file: "); scanf("%s",srcfile);

       printf("nDestination file: "); scanf("%s",dstfile);

       printf("nPassword (up to 255 chars): ");

       //the start of the key preparation process

       for (int i=0; i<255; i++)

            key[i]='§';

       scanf("%s",key); int temp=0; char key_backup[255];

       for (i=0;i<255;i++)

       {

            if (key[i]=='')

               break;

            temp=i;

       }

       strcpy(key_backup, key);

       for (i=temp; i>=0; i--)

           key[temp-i]=key[temp-i] & (~key_backup[i]);

       //key preparation process is done; we're ready to XOR!

       ifstream s(srcfile, ios::binary);

       ofstream d(dstfile, ios::binary);

       if (!s || !d)

           printf("nERROR: Couldn't open one of the files!");

       i=0; char c;

       while ((s.read((char*)&c, sizeof(c))))

       {

           if (key[i]=='')

              i=0;

           c=key[i] ^ c;

           d.write((char*)&c, sizeof(c));

           i++;

       }

       s.close();  d.close();

       printf("nAll done. ");

    }

    Once again, the download button below leads to an archive that contains the ready-to-run executable and source code of the above algorithm. Enjoy!

    More Security Articles
    More By Barzan "Tony" Antal


       · Thanks for reading; I really appreciate it. If you want to leave any feedback then...
     

       

    SECURITY ARTICLES

    - LAN Reconnaissance
    - An Epilogue to Cryptography
    - A Sequel to Cryptography
    - An Introduction to Cryptography
    - Security Overview
    - Network Security Assessment
    - Firewalls
    - What’s behind the curtain? Part II
    - What’s behind the curtain? Part I
    - Vectors
    - PKI: Looking at the Risks
    - A Quick Look at Cross Site Scripting
    - PKI Architectures: How to Choose One
    - Trust, Access Control, and Rights for Web Se...
    - Basic Concepts of Web Services Security

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT