Solved

decoder encoder

Posted on 1998-02-12
9
330 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
Comment Utility
What's you question?
0
 
LVL 1

Expert Comment

by:jasonf
Comment Utility
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
Comment Utility
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
 

Author Comment

by:latino
Comment Utility
Still evaluating your answer ready thanks
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 84

Expert Comment

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

Expert Comment

by:Ready4Dis
Comment Utility
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
Comment Utility
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
Comment Utility
Nothing wrong with that, as long as you understand it.
0
 

Author Comment

by:latino
Comment Utility
thks all!!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now