Dear All,
How to encrypt a C data file and make binary file and then have to read
a bin file at run time and decrypt the file and have to read the data.
Any help to achive this pls. Would be great if any sample source code
provided.
Thanks,
Sweety 9 5106
sweety wrote: Dear All,
How to encrypt a C data file and make binary file and then have to read a bin file at run time and decrypt the file and have to read the data.
Any help to achive this pls. Would be great if any sample source code provided.
Thanks, Sweety
I don't really know what you mean. Could you give me an example, or tell
me about the overall goal of acutally doing such a thing?
sweety wrote: Dear All,
How to encrypt a C data file and make binary file and then have to read a bin file at run time and decrypt the file and have to read the data.
Any help to achive this pls. Would be great if any sample source code provided.
fopen() the file, in text or binary mode, as appropriate.
If your encryption algorithm depends on context w.r.t. the
input, read in the whole file (use either fread() or getc()
and malloc()/realloc() for the buffer).
Encrypt.
fopen() the output file in "b" binary mode. Write the output
to it. fclose() input and output file.
Essentially the same applies to the decryption part.
If you provide us with your best shot at it (minus the
encryption or decryption part), we may help you further
with the standard C part of it.
If you want some sort of dummy encryption/decryption for the
code you post, use a simple one, e.g. Caesar cipher.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
"sweety" <ur********@gmail.com> wrote How to encrypt a C data file and make binary file and then have to read a bin file at run time and decrypt the file and have to read the data.
Any help to achive this pls. Would be great if any sample source code provided.
If you use the XOR operation, you can apply the operation once to flip
arbitrary bits, and twice to retrieve the original information.
So a simple scheme would XOR everything with a constant value, say 0x55.
This is too easy to break - simply by counting the commonest character you
can get the spaces, then the 'e's, then the 't's, assuming you are crypting
English text.
So an improvement is to have a pseudo-random number generator. You seed it
with your secret seed, and then XOR with the numbers that come out. This is
much harder to break.
To do a really professional job, you need to implement a completely
differenent schme, like RSA, which is built on the fact that it is
impossible to factorise large numbers in reasonable time, if the factors are
also large, but it is very easy to create such numbers by multiplying
together two large primes.
In article <ds*********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com>,
Malcolm <re*******@btinternet.com> wrote:
.... To do a really professional job, you need to implement a completely differenent schme, like RSA, which is built on the fact that it is impossible to factorise large numbers in reasonable time, if the factors are also large, but it is very easy to create such numbers by multiplying together two large primes.
I see you've been talking to Bill Gates...
On 4 Feb 2006 23:12:09 -0800, in comp.lang.c , "sweety"
<ur********@gmail.com> wrote: Dear All,
How to encrypt a C data file and make binary file and then have to read a bin file at run time and decrypt the file and have to read the data.
This is an algorithms or cryptology question. Why not ask in more
appropriate groups?
Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
"Malcolm" <re*******@btinternet.com> writes: "sweety" <ur********@gmail.com> wrote How to encrypt a C data file and make binary file and then have to read a bin file at run time and decrypt the file and have to read the data.
Any help to achive this pls. Would be great if any sample source code provided.
If you use the XOR operation, you can apply the operation once to flip arbitrary bits, and twice to retrieve the original information.
So a simple scheme would XOR everything with a constant value, say 0x55.
This is too easy to break - simply by counting the commonest character you can get the spaces, then the 'e's, then the 't's, assuming you are crypting English text.
So an improvement is to have a pseudo-random number generator. You seed it with your secret seed, and then XOR with the numbers that come out. This is much harder to break.
To do a really professional job, you need to implement a completely differenent schme, like RSA, which is built on the fact that it is impossible to factorise large numbers in reasonable time, if the factors are also large, but it is very easy to create such numbers by multiplying together two large primes.
There are plenty of commercial and freeware encryption programs out
there. If you try to implement your own, it will almost certainly be
breakable *unless* you know a lot more about encryption than, for
example, I do. For example, depending on the rand() function provided
with your C implementation is unlikely to give you good encryption.
sci.crypt is a good place to ask for more information.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
"Keith Thompson" <ks***@mib.org> wrote There are plenty of commercial and freeware encryption programs out there. If you try to implement your own, it will almost certainly be breakable *unless* you know a lot more about encryption than, for example, I do. For example, depending on the rand() function provided with your C implementation is unlikely to give you good encryption.
Let's say we are terrorists planning an attack on America.
Now we implement a simple scheme to encrypt our emails.
If the CIA, FBI, or whatever know who we are, of course they will shell out
twenty dollars an hour for a programmer to break our rand().
However what if there are hundreds of thousands of moon-worshipers in the
world, all of whom hate the USA? They can't afford twenty dollars a shot for
every message.
Probably they just run intercepted emails through standard decrypts, and
pick out key words and phrases, like "moon is auspicious for an attack" .
So we have a substantial degree of safety.
"Malcolm" <re*******@btinternet.com> writes: "Keith Thompson" <ks***@mib.org> wrote There are plenty of commercial and freeware encryption programs out there. If you try to implement your own, it will almost certainly be breakable *unless* you know a lot more about encryption than, for example, I do. For example, depending on the rand() function provided with your C implementation is unlikely to give you good encryption. Let's say we are terrorists planning an attack on America.
Now we implement a simple scheme to encrypt our emails. If the CIA, FBI, or whatever know who we are, of course they will shell out twenty dollars an hour for a programmer to break our rand(). However what if there are hundreds of thousands of moon-worshipers in the world, all of whom hate the USA? They can't afford twenty dollars a shot for every message.
Probably they just run intercepted emails through standard decrypts, and pick out key words and phrases, like "moon is auspicious for an attack" .
So we have a substantial degree of safety.
You're assuming it costs $20 per message. Given a weak encryption
method, it's more likely to cost, say, $20 to break the encryption,
then a fraction of a cent (if that much) to decrypt each message.
If you care *at all* about security, there are plenty of freely
available encryption programs that are almost certainly many orders of
magnitude more difficult to crack than anything I, for one, could come
up with on my own.
Why would anyone settle for a "substantial degree of safety" when a
much higher degree of safety is free?
If you just want to play around, of course, there's nothing wrong with
trying to write your own encryption code -- just don't depend on it
unless you happen to be an expert.
And this is entirely off-topic for comp.lang.c. You'll find the
experts on this topic (definitely not including me) in sci.crypt.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
sweety said: Dear All,
How to encrypt a C data file
Putting the word "C" into an article doesn't make it topical in comp.lang.c!
and make binary file and then have to read a bin file at run time and decrypt the file and have to read the data.
The answer to this question depends on your threat model, and on the balance
you are prepared to strike between performance, security, and key
distribution, and on your skill level with C, and so on and so forth.
If you want something that'll stop a major government from reading your
data, you'd be well-advised to use a well-analysed algorithm such as
Rijndael (AES) or TwoFish.
If you just want something that'll stop your kid sister from reading your
data, a simple Feistel network in CBC mode with a primitive round function
based on a 64-bit key is probably sufficient.
Caveat: if your kid sister works for a major government in a cryptology
capacity, go for the first option, not the second.
I recommend "Applied Cryptography", 2nd edition, by Bruce Schneier, or
"Handbook of Applied Cryptography" (legally available online for free, from
<http://www.cacr.math.uwaterloo.ca/hac/> for some useful insights into
designing cryptographical algorithms - but please remember that no
algorithm you can design yourself is going to give a clueful user the same
"feel safe" factor as a properly-analysed algorithm designed by experts.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: wqhdebian |
last post by:
As far as I know,when encrypt or decrypt ,a key must first be got,and
the key is first generate by a tool or from SecurityRandom,that means
I can not generate the same key with the same input.Does...
|
by: Hrvoje Voda |
last post by:
Does anyone knows a good example of how to encrypt/decrypt a string?
Hrcko
|
by: Gidi |
last post by:
Hi,
Is there Buid-In fuction in C# that Encrypt and Decrypt strings?
i have a textbox which i'm writing into file, and i want to encrypt it
before writing, i'm not looking for something fancy,...
|
by: Jean Christophe Avard |
last post by:
Hi! I am designing an application wich comes with image file. These images
are copyrighted and they have to be accessible only from within the
application. At first, I tought I was going to store...
|
by: DazedAndConfused |
last post by:
Can you encrpt a serialized object?
Or am I trying to do something that just doesn't work that way?
I am trying to encrypt a serialized object. I can read and write the object
to a file...
|
by: sweety |
last post by:
Dear All,
I need to encrypt a C data file(Filled structure data and int, enums).
and make a bin file. The at anypoint of time i've to read this .bin
file and have to decrypt and have to read the...
|
by: Islamegy® |
last post by:
I give up.. I tried everything to encrypt querystring and decrypt it back
but this never success.. i use RSA encryption. I always get excption when
Convert fromBase64String so i tried...
|
by: JDeats |
last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting
and decrypting a file.
http://support.microsoft.com/kb/307010
In .NET 2.0 this approach is not fully supported (a .NET 2.0...
|
by: FarooqRafiq |
last post by:
Hi,
My requirement is that a string is encrypted in VB.NET and sent to PHP, PHP decrypts the string (till here the logic is working) and then the PHP should encrtyp (where i am having problems)...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |