Connecting Tech Pros Worldwide Help | Site Map

Suggestions for Encryption Algorithms and Languages?? [ I'm new at this ]

Robert Blass
Guest
 
Posts: n/a
#1: Sep 17 '08
I am looking to get my feet wet with encryption. When I say encryption
program I am talking about something to get me off to a quick start.
Something very simple, far less than the 40+ bit encryption code.

What I need is an easy to understand language choice. I've used BASIC
a long time ago but is there another language that is better and more
supported?

There seems to be hundreds of languages so it's hard for me to just
pick one.

I also wanted it to be a freeware or shareware programming language
with a compiler and maybe an editor that has colors and error
checking. I'll need it to be usable in a windows/xp environment.
Maybe a one that compiles into a self supportive EXE?

As I said I am just starting by trying to code a very simple
encryption program. If anything fits this bell then please give me
some information.

Thanks.

Message was cross-posted to the following Newsgroups in hopes of
getting more replies.
comp.lang.basic.powerbasic,comp.lang.misc,comp.lan g.java,comp.lang.c++,comp.lang.c,comp.lang.c.moder ated

William Pursell
Guest
 
Posts: n/a
#2: Sep 18 '08

re: Suggestions for Encryption Algorithms and Languages?? [ I'm new at this ]


On 17 Sep, 23:20, Richard Heathfield <r...@see.sig.invalidwrote:
Quote:
>
Here's an appallingly simple encryption program, in C:
>
#include <stdio.h>
#include <stdlib.h>
>
int encrypt(const char *infile, const char *outfile, const char *keyfile)
{
* int rc = 1;
* FILE *in = fopen(infile, "rb");
* if(in != NULL)
* {
* * FILE *out = fopen(outfile, "wb");
* * if(out != NULL)
* * {
* * * FILE *key = fopen(keyfile, "rb");
* * * if(key != NULL)
* * * {
As a matter of style, it might be better to save
multiple levels of indentation by doing something like:
in = fopen ...
out = fopen ...
key = fopen ...
if( in != NULL && out != NULL && key != NULL )
...

But overall easier to use a wrapper function that
prints a proper error message and exits. IMO, it
is laudable to check the return value of fopen,
but incomplete to silently do so. Failures
must be loud. eg:

in = fopen( infile, "rb" );
if( in == NULL ) {
perror( infile );
}
(Standard caveat: not all implementations produce
a useful error message because fopen fails to set
errno.)
Quote:
* * * * int inbyte = 0;
* * * * int keybyte = 0;
* * * * int outbyte = 0;
* * * * rc = 0;
* * * * while((inbyte = getc(in)) != EOF)
* * * * {
* * * * * keybyte = getc(key);
* * * * * if(keybyte == EOF)
* * * * * {
* * * * * * rewind(key);
* * * * * * keybyte = getc(key);
* * * * * }
* * * * * outbyte = inbyte ^ keybyte;
* * * * * putc(outbyte, out);
* * * * }
* * * * fclose(key);
* * * }
* * * fclose(out);
* * }
* * fclose(in);
Hmmm. What happens on IO errors? You need to
check for all errors, Richard! You know that.

It would be much more useful for this function
to take FILE * arguments instead of filenames,
since that would allow the main routine to
pass stdin and stdout as parameters. There's
no need to make the program work only on regular
files, although key needs to be regular for
the rewind to work. (Hmmm, let's test the original
program with a fifo for key and see what happens...
haven't compiled it, but I believe the rewind will
fail and the getc will block.)
Quote:
* }
* return rc;
>
I'm curious to know what 'rc' stands for. I usually
use rc to mean "read count" and write (non-standard)
rc = read( ... ), while returning a variable named
'status'.

--
William Pursell
Richard Heathfield
Guest
 
Posts: n/a
#3: Sep 18 '08

re: Suggestions for Encryption Algorithms and Languages?? [ I'm new at this ]


William Pursell said:
Quote:
On 17 Sep, 23:20, Richard Heathfield <r...@see.sig.invalidwrote:
Quote:
>>
>Here's an appallingly simple encryption program, in C:
>>
<snip>
Quote:
As a matter of style, it might be better to save
multiple levels of indentation by doing something like:
in = fopen ...
out = fopen ...
key = fopen ...
if( in != NULL && out != NULL && key != NULL )
Fine. I disagree, but - as you say - it's a matter of style.
Quote:
But overall easier to use a wrapper function that
prints a proper error message and exits. IMO, it
is laudable to check the return value of fopen,
but incomplete to silently do so. Failures
must be loud.
Which bit of "appallingly simple" are you struggling to understand? The
program was written, from scratch, in about three minutes. You're *right*,
of course, but I had a reason for keeping the code short and simple.
Quote:
Quote:
>return rc;
>>
>
I'm curious to know what 'rc' stands for. I usually
use rc to mean "read count" and write (non-standard)
rc = read( ... ), while returning a variable named
'status'.
I first came across the rather cryptic:

RC=4

in 1982, in the hey-day of VM/CMS and CP. I eventually discovered that it
stood for "return code": 0 meant success, 4 meant "hmmm", and 12 or
possibly 16 meant "eek!"

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
CBFalconer
Guest
 
Posts: n/a
#4: Sep 20 '08

re: Suggestions for Encryption Algorithms and Languages?? [ I'm new at this ]


Robert Blass wrote:
Quote:
>
So what's your opinion of Dr Java??
This is both off-topic (on c.l.c) and top-posted. Don't do either.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Richard Heathfield
Guest
 
Posts: n/a
#5: Sep 20 '08

re: Suggestions for Encryption Algorithms and Languages?? [ I'm new at this ]


Robert Blass said:
Quote:
So what's your opinion of Dr Java??
I don't have an opinion of Dr Java. I do, however, have a search engine, so
I was able to discover that "DrJava is a lightweight development
environment for writing Java programs. It is designed primarily for
students, providing an intuitive interface and the ability to
interactively evaluate Java code. It also includes powerful features for
more advanced users. DrJava is available for free under the DrJava Open
Source License, and it is under active development by the JavaPLT group at
Rice University."

I'm not sure what the above has to do with C or with encryption. Encryption
doesn't add value to data - quite the opposite, in fact - and to persuade
people to do it you have to make it as non-intrusive as possible, and that
means as fast as possible, and that generally means C.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Closed Thread