473,387 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

encrypting a string in C using XTEA

4
Hello,

I'm trying to encrypt the final output of my program. This final output is a char buffer, a string, the encrypted form of which I'd like to save to a text file. I have the XTEA code working, but I'm not sure how to use it with a string rather than a long int. Here's the XTEA code, for reference:

Expand|Select|Wrap|Line Numbers
  1. void encipher(const unsigned long *const v,unsigned long *const w,
  2.    const unsigned long * const k)
  3. {
  4.    register unsigned long       y=v[0],z=v[1],sum=0,delta=0x9E3779B9,n=32;
  5.  
  6.    while(n-->0)
  7.       {
  8.       y += (z << 4 ^ z >> 5) + z ^ sum + k[sum&3];
  9.       sum += delta;
  10.       z += (y << 4 ^ y >> 5) + y ^ sum + k[sum>>11 & 3];
  11.       }
  12.  
  13.    w[0]=y; w[1]=z;
  14. }
  15.  
  16. void decipher(const unsigned long *const v,unsigned long *const w,
  17.    const unsigned long * const k)
  18. {
  19.    register unsigned long       y=v[0],z=v[1],sum=0xC6EF3720,
  20.                 delta=0x9E3779B9,n=32;
  21.  
  22.    /* sum = delta<<5, in general sum = delta * n */
  23.  
  24.    while(n-->0)
  25.       {
  26.       z -= (y << 4 ^ y >> 5) + y ^ sum + k[sum>>11 & 3];
  27.       sum -= delta;
  28.       y -= (z << 4 ^ z >> 5) + z ^ sum + k[sum&3];
  29.       }
  30.  
  31.    w[0]=y; w[1]=z;
  32. }
  33.  
Thanks in advance.
Sep 10 '07 #1
0 2070

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: steve | last post by:
Hi, I know there are a few free and paid php source code encryption scripts around. Has anyone used one, and any feedback? I am interested in encrypting source that is placed on a remote host....
3
by: Piotr | last post by:
MS has published on its sites javascript encoder, which enables "encrypting" javascript code. It allows hiding js code from being seen as a text file. There is a decoder for it, available in the...
7
by: Bob Hollness | last post by:
OK, this has me pulling my hair out. All I want to do is encrypt/decrypt strings. They may be up to 400 characters in length though. So, I assume System.Security.Cryptography is the one to use....
7
by: Richard L Rosenheim | last post by:
Anyone care to express their two cents over pros and cons of encrypting the data being transmitted (within the SOAP package) versus just utilizing a HTTPS connection? Richard Rosenheim
11
by: frizzle | last post by:
Hi there, I need an encrypting function, but haven't got a clue where to start. First a string has to be encrypted with two different encryption keys. Both output should be anything a-z / A-Z /...
5
by: Chris Dunaway | last post by:
I have an application which is installed on a network share to be run from one or more workstations. I have granted trust to the applications on the workstations and the appropriate permissions on...
2
by: Parrot | last post by:
I cannot get an answer as to why my session state no longer remains active between webpages after working for 2 years. So I want to try to pass data thru query strings in my url. I tried to use...
2
by: SeeSharp Bint | last post by:
Visual Studio 2005, dotnet, c#. Microsoft SQL Server. Windows XP forms application. Temporarily, for my database application, I have been storing the various elements of database connection...
3
by: Tery | last post by:
I'm trying to implement the Handango.com HTTP POST registration method. The instructions are here: http://www.handango.com/marketing/developerTeam/HTTP_Post_Reg_Model_How2.doc I'm stuck on how...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.