Reading a file with Courier New characters

This is a discussion on Reading a file with Courier New characters within the C Programming forums, part of the General Programming Boards category; Hi to who ever can help... I am busy writing an encryption engine that reads a file programmed using VHDL ...

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    2

    Unhappy Reading a file with Courier New characters

    Hi to who ever can help...

    I am busy writing an encryption engine that reads a file programmed using VHDL and encrypting it. My problem is that the file uses characters. I managed to find these characters in Word document under Courier New symbols. My encryption engine works on 8 bytes blocks, meaning that I read 8 bytes, encrypt them and save them to the output file. If I read the file using a char variable, the file is not read at all. If I use an int variable it reads and encrypt the file but I am not sure that the encryption operation is then correct because the manipulation of the data now deals with 8 integers and not 8 char characters... Any suggestions? Does anyone know how long are these characters? Can I read them as integers and then convert them to single chars? If yes then how long is an int variable in Visual C++? Any help will be really appreciated!!!

    Thanks, Noam.
    Last edited by Noam; 07-07-2006 at 03:52 AM. Reason: Correction...

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,541
    > meaning that I read 8 bytes, encrypt them and save them to the output file
    If you're doing
    FILE *fp = fopen("file","rb");

    And to read the file
    unsigned char buff[8];
    fread( buff, 8, 1, fp );

    Then there is nothing to worry about. Any half-decent encryption shouldn't give a monkeys what the data in the file is.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jul 2006
    Posts
    2
    Thanks for the replay!!! I actualy managed to work it through!!!
    I have a new problem though with the fputc function...
    It seemes like there is a slip protocol that addes "stuffing" bytes to the saved message. Is there any way around it? If not are you familiar with the slip protocol - If I knew when a stuffing byte is added I could ignore it on the other side....

    Thanks again, Noam.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,541
    Why would the protocol matter?
    Whatever gets added by the protocol to "wrap" up the message going out should be removed when the message is received.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 02:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21