Gossamer Forum
Home : General : Perl Programming :

encription Algorithym

Quote Reply
encription Algorithym
Does anyone have any algorithym for encrypitng some data, but have an algorithm to decrypt it?
I dont want to use the crypt() function because we cant decrypt that...

Can anyone help?
Quote Reply
Re: encription Algorithym In reply to
Quote Reply
Re: encription Algorithym In reply to
Thanks GClemmons.
It worked greatly!!!
Quote Reply
Re: encription Algorithym In reply to
mmmh.... for me it prints only:

Test = $test



Quote Reply
Re: encription Algorithym In reply to
Then you don't know anything about basic perl variable interpolation.

You might want to read some basic documentation on Perl.
perldoc perldoc

-- Gordon


s/(\d{2})/chr($1)/ge + print if $_ = '8284703280698276687967';
Quote Reply
Re: encription Algorithym In reply to
It seems I don't know it :(
Please tell me more as this seems only a wrong code. For me and many other readers. Sorry.

Quote Reply
Re: encription Algorithym In reply to
You and 'many other readers' should try looking at the code you are trying to copy a little closer if you don't know anything about Perl. If you aren't interpolating your variables, they show up as regular strings.
Just be a good script kiddie and copy and paste.
In the mean time, look at these two pieces of code and compare their outputs.

my $test = 'blah';
print "$test\n";

and

my $test = 'blah';
print '$test\n';

-- Gordon


s/(\d{2})/chr($1)/ge + print if $_ = '8284703280698276687967';
Quote Reply
Re: encription Algorithym In reply to
Ok but I don't understand... in the code ...

-----
print "Encrypted test = $etest\n";
print "Decrypted test = $dtest\n";
-----
print nothing!!

Quote Reply
Re: encription Algorithym In reply to
oh c'mon... did you read the original post with the code? Just copy the two pieces and run it..

#!/usr/bin/perl

my $master_key = 22;
my $salt = 3;
my $test = 'this is a test';
print "Test = $test\n";
my $etest = encrypt($test, $master_key, $salt);
print "Encrypted test = $etest\n";
my $dtest = decrypt($etest, $master_key, $salt);
print "Decrypted test = $dtest\n";

sub encrypt {
my ($data, $key, $salt) = @_;
my $edata;
$edata .= $_ = ord($_) * ($key += $salt) . '|' foreach (split //, $data);
return ($edata);
}

sub decrypt {
my ($data, $key, $salt) = @_;
my $ddata;
$ddata .= $_ = chr($_ / ($key += $salt)) foreach (split /\|/, $data);
return ($ddata);
}

--Mark

Installation support is provided via ICQ at UIN# 53788453. I will only respond on that number.
Quote Reply
Re: encription Algorithym In reply to
Hello Mark,

sorry, but I get the following error:

syntax error at crypt2.cgi line 15, near "'|' foreach "

which is this line:
Code:
$edata .= $_ = ord($_) * ($key += $salt) . '|' foreach (split //, $data);
syntax error at crypt2.cgi line 22, near ") foreach "

which is this line:
Code:
$ddata .= $_ = chr($_ / ($key += $salt)) foreach (split /\|/, $data);
xxx.cgi had compilation errors.

Del.

Quote Reply
Re: encription Algorithym In reply to
what is the enitre source to the file you arer trying to execute. and what version of perl?

--mark

Installation support is provided via ICQ at UIN# 53788453. I will only respond on that number.
Quote Reply
Re: encription Algorithym In reply to
The perl version: 5.00402

The source (3-Jun-00 03:29 by Mark):

#!/usr/bin/perl

my $master_key = 22;
my $salt = 3;
my $test = 'this is a test';
print "Test = $test\n";
my $etest = encrypt($test, $master_key, $salt);
print "Encrypted test = $etest\n";
my $dtest = decrypt($etest, $master_key, $salt);
print "Decrypted test = $dtest\n";

sub encrypt {
my ($data, $key, $salt) = @_;
my $edata;
$edata .= $_ = ord($_) * ($key += $salt) . '|' foreach (split //, $data);
return ($edata);
}

sub decrypt {
my ($data, $key, $salt) = @_;
my $ddata;
$ddata .= $_ = chr($_ / ($key += $salt)) foreach (split /\|/, $data);
return ($ddata);
}

Quote Reply
Re: encription Algorithym In reply to
Dunno. I cut and paste that source directly from your posting, and it runs just fine... I have no idea why it isn't working for you.

--mark

Installation support is provided via ICQ at UIN# 53788453. I will only respond on that number.
Quote Reply
Re: encription Algorithym In reply to
 
When I first tried the routine a month or so ago it worked fine on win98. I had activestate's version on win98.

I have tried since on win98 and I have the same error as DelPierro.
I am now using CPAN's windows version 5.00402
from http://www.perl.com/.../win32/Standard/x86/

There must be someting unusual from that version,
it works ok my linux perl 5.6

Perhaps DelPierro is using the perl I have from CPAN.

rog

Quote Reply
Re: encription Algorithym In reply to
That could be! The Activestate win version of 5.6 is hosed. I would get errors with that thing with a program consiting of noting more than:

Code:
#!/usr/bin/perl

use DBI;
So I wouldn't be surprised. I've since migrated all of my win machines back to build 522

--mark

Installation support is provided via ICQ at UIN# 53788453. I will only respond on that number.
Quote Reply
Re: encription Algorithym In reply to
Great it works with almost all files. I found problems with microsoft files (.doc .xls, etc).
You can encrypt but not decrypt the files.

Quote Reply
Re: encription Algorithym In reply to
Files??
This was designed to work with a *nix standard password string for CGI data transfers, not for entire file encyptions!

-- Gordon


s/(\d{2})/chr($1)/ge + print if $_ = '8284703280698276687967';
Quote Reply
Re: encription Algorithym In reply to
OK! Are there any programmers who could help me develop an algorithm for encrypting and decrypting *all* files using a user password? Please let me know.

Quote Reply
Re: encription Algorithym In reply to
Sure, Mark and I both are available to hire for $400.00 an hour. If you want a good file encryption algorythm that ranges beyond standard text files you can pay us or start digging through freshmeat and hope for something that works:)

-- Gordon


s/(\d{2})/chr($1)/ge + print if $_ = '8284703280698276687967';