Sponsored Content
Top Forums Programming how to write a file to binary format in C ? Post 302334746 by jim mcnamara on Thursday 16th of July 2009 10:35:30 AM
Old 07-16-2009
binary and text files ideas are really baggage from windows. The unix file system does not know about binary and text. Simply using fopen("filename", "wb") (open for binary writing) will not make the text unreadable. If you are doing this to hide passwords - don't ever try to write security stuff to a file without real encryption.

Bad idea.

If the information is sensitive, try crpyt. You edit a file then use crpyt to encrypt it.
crypt also decrypts the data. While crypt is not perfect protection it is okay inside the confines of a secure system.

If you are sending this data out on the internet try GNU gpg.

If you are just playing, look into XOR "encryption"
XOR cipher - Wikipedia, the free encyclopedia
The XOR bitwise operator ^ in C can do this for you.
 

10 More Discussions You Might Find Interesting

1. Programming

Binary to text format conversion

Hi, Please can any one tell me how to convert binary data to text format and vice versa. If possible give me the algorithm or C program. Thanks in advance Waiting for reply Bye:o (5 Replies)
Discussion started by: manjunath
5 Replies

2. UNIX for Dummies Questions & Answers

write data into a text file in bold format

Hi, can anyone help to write data into a text file in bold format and rollback to actual format. Thanks, Regards, Milton Y. (1 Reply)
Discussion started by: miltony
1 Replies

3. Programming

Reading a binary file in text or ASCII format

Hi All, Please suggest me how to read a binary file in text or ASCII format. thanks Nagendra (3 Replies)
Discussion started by: Nagendra
3 Replies

4. Shell Programming and Scripting

Is there any script which convert binary file to CSV format

Dear guys; I have a binary file and I need to convert its data to csv format ...appreciating your help. Best Regards (14 Replies)
Discussion started by: ahmad.diab
14 Replies

5. UNIX for Dummies Questions & Answers

Converting binary file to readable format in Ksh

In Unix/Ksh, when I try to look inside a file it says that the file may be a binary file and if I want to see it anyway. When i say 'yes', it shows me the content filled with unreadable symbols (looks like binary). Is there a command that I can run from the Unix prompt to convert/translate that... (3 Replies)
Discussion started by: arthurs
3 Replies

6. Shell Programming and Scripting

How to write shell script for input file name format checking?

Hello, I had written a shell script that accepts input file as cmd line argument and process this file. if ; then if ; then . $1 LOGFILE="$LOG_FILE/MIG_BIOS.log"; get_input_file else ERROR_CODE=MSCRM0005_003 error "$ERROR_CODE : Input file $1 is not available"; exit... (3 Replies)
Discussion started by: Poonamol
3 Replies

7. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

8. Shell Programming and Scripting

Convert binary file to csv and then back to the binary format

Hello *nix specialists, Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies

9. Shell Programming and Scripting

Convert jpg file to binary format

Hi Team, Here's the requirement. I have a image file in jpg format in unix. Now I need to i. convert the jpg format to binary format ii. followed by loading the binary file to Oracle db. Can anyone help me out? Thanks Krishnakanth Manivannan (4 Replies)
Discussion started by: kmanivan82
4 Replies

10. UNIX for Advanced & Expert Users

Binary write POSIX-ly.

Hi guys and gals... I am now beyond the limits of my POSIX knowledge here. Below is a piece of code that runs perfectly well on small string lengths, BYTE sizes up to around 1KB, (3KB of octal text). It generates byte vlues from 0x00 to 0xFF. It passes Shell Check's requirements and... (6 Replies)
Discussion started by: wisecracker
6 Replies
crypt(1)						      General Commands Manual							  crypt(1)

NAME
crypt - encode/decode SYNOPSIS
crypt key < input.File > output.File DESCRIPTION
The command reads from the standard input and writes on the standard output. You must supply a key which selects a particular transforma- tion. If no password is given, demands a key from the terminal and turns off printing while the key is being typed in. The command encrypts and decrypts with the same key. Files encrypted by are compatible with those treated by the ed, ex and vi editors in encryption mode. The security of encrypted files depends on three factors: the fundamental method must be hard to solve, direct search of the key space must be infeasible, and sneak paths by which keys or clear text can become visible must be minimized. The command implements a one-rotor machine designed along the lines of the German Enigma, but with a 256-element rotor. Methods of attack on such machines are known, but not widely; moreover the amount of work required is likely to be large. The transformation of a key into the internal settings of the machine is deliberately designed to be expensive, for example, to take a sub- stantial fraction of a second to compute. However, if keys are restricted to three lowercase letters, then encrypted files can be read by expending only a substantial fraction of five minutes of machine time. Since the key you choose is an argument to the command, it is potentially visible to users executing the command or a derivative. To mini- mize this possibility, destroys any record of the key immediately upon entry. The most vulnerable aspect of is the choice of keys and key security. EXAMPLES
The following examples use KEY as the key to encrypt and decrypt files. The first example encrypts the file naming the resulting encrypted file The second example decrypts the file naming the resulting decrypted file The third example prints the encrypted file in clear text. $ crypt KEY < plain.File > crypt.File $ crypt KEY < crypt.File > decrypt.File $ crypt KEY < crypt.File | pr FILES
for typed key RELATED INFORMATION
ed(1), ex(1), vi(1), crypt(3), makekey(8) delim off crypt(1)
All times are GMT -4. The time now is 04:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy