Solved

decoder encoder

Posted on 1998-02-12
9
348 Views
Last Modified: 2012-05-04
encoder decorer in C language
0
Comment
Question by:latino
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 3

Expert Comment

by:q2guo
ID: 1257223
What's you question?
0
 
LVL 1

Expert Comment

by:jasonf
ID: 1257224
Do you mean you want to emulate a TTL 2 to 4 line decoder/encoder, for example, in software?  If so, how many lines (eg. 2 to 4, 3 to 8, etc.) and do you want to have an enable signal (like a TTL part)?
0
 
LVL 2

Accepted Solution

by:
Ready4Dis earned 50 total points
ID: 1257225
Here is an encrypter/decrypter...
#include <conio.h>
#include <stdio.h>
#include <string.h>

main (int arg, char *argv[])
{
      int does,add,times;
      char temp,key,*did;
      FILE *in,*out;
      if (arg<4) {
            printf("Use: Crypt -E/-D Infile Outfile\n");
            printf("-E   Encrypt/-D   Decrypt");
            return -1;
      }
      if (!strcmpi(argv[1],"-E")) does=1;
      if (!strcmpi(argv[1],"-D")) does=2;
      printf("What is the four key password: ");
      times=0;
      while (times<2) {
            key=getche();
            times++;
            add+=key;
      }
      times=0;
      while (times<2) {
            key=getche();
            times++;
            add-=key;
      }
      if (does==2) add=-add;
      times=0;
      clrscr();
      in=fopen(argv[2],"rb");
      out=fopen(argv[3],"wb");
      if (does==2) printf("File: ");
      while (!feof(in)){
            temp=fgetc(in);
            times++;
            if (feof(in)) {
            if (does==2) did="Decrypting";
            else did="Encrypting";
            printf("\n");
            printf("Done %s %s\n",did,argv[2]);
            printf("Size: %d -Bytes",times-1);
            return 0;
            }
            temp+=add;
            fputc(temp,out);
            if (does==2) printf("%c",temp);
      }
      return 0;
}
0
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

Author Comment

by:latino
ID: 1257226
Still evaluating your answer ready thanks
0
 
LVL 84

Expert Comment

by:ozo
ID: 1257227
You should know that it's pretty easy to crack that encryption.
0
 
LVL 2

Expert Comment

by:Ready4Dis
ID: 1257228
Yes, it's easy, but it is just s simple example for him to learn from, not the source to a government agency's encryption program.
0
 
LVL 2

Expert Comment

by:Ready4Dis
ID: 1257229
Yes, it's easy, but it is just s simple example for him to learn from, not the source to a government agency's encryption program.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1257230
Nothing wrong with that, as long as you understand it.
0
 

Author Comment

by:latino
ID: 1257231
thks all!!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to show menu 5 88
Line meaning 9 85
What is atomic operation? 6 58
How to pass pointer to int when expected type is pointer to const char *   ? 6 22
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question