Jump to content
xisto Community
Sign in to follow this  
k221405241470

Crypto Program A perl script to protect data

Recommended Posts

If you'd like to protect you doc without the standard program and algorithms you'll fide it useful,

Now the only big problem is the ARRAY pased to the subs, in fact I can't pass 2 @ at the same Sub so I have to use a global array(@plus) in the subroutines, SomeOne knows if is it possibile to pass 2 @ to a sub? if yes how?

#!/usr/bin/perl#************Random Signature V1,0******************##* CodeName: Crypto v1.7 alpha                     *##* Coder: K22 - 
http://forums.xisto.com/no_longer_exists/
;         *##* Date: 07/11/2004;                                *##* License: GNU/GPL;                               *##***************************************************#sub keygen {                    #Generate a code from a char, not just a simple ASCII#my (@togen,@plus)=@_;my @plus=@plus;my @togen=@_;my $i=0;#print $plus[0]."-0-".$plus[1]."-1-".$plus[2]."-2-".$plus[3]."-3-\n";foreach $chr(@togen) {$ascii=ord($chr);$togen[$i]=$ascii+$#togen+ord($#togen)+$plus[0]-$plus[1]-(($plus[2]-$plus[3])*2)+$#plus-ord($#plus);$i++;}   return (@togen);}sub degen {                     #Degenerate the coede made by the keygen function#my (@tode,@plus)=@_;my @plus=@plus;my @tode=@_;my $i=0;#print $plus[0]."-0-".$plus[1]."-1-".$plus[2]."-2-".$plus[3]."-3-\n";foreach $chrz(@tode) {$ascii=$chrz-$#tode-ord($#tode)-$plus[0]+$plus[1]+(($plus[2]-$plus[3])*2)-$#plus+ord($#plus);$tode[$i]=chr($ascii);$i++;} return (@tode);}sub alphagen {                 #Alpha generator, it's a new function, I'll use ti for modify the lenght of the output$let="a";for($i=1;$i<=26;$i++){push(@alpha,$let);$let++;}return (@alpha);}sub relpos {                 #Calculations of valide array positionsmy ($y,$limit,@refarr)=@_;my $p=0;my @val;for($p=0;$p<=$limit;$p++){$y=$_[0]+$p;while(!exists($refarr[$y])){$val[4].= $#refarr."s-$p\n";$y=$y-$#refarr-1;$val[4].= $y."p-$p\n";}$val[$p]=$y;}return(@val);}sub divi(@){                    #Generator of passwd numbermy @whr=@_;my $temp;$temp=$secpass[$whr[0]]*$secpass[$whr[1]];$temp=$temp*($secpass[$whr[0]]+$secpass[$whr[1]]-$secpass[$whr[2]]);return($temp);}sub ende {                         #Core of the algorithmsmy ($cho,@toende)=@_;my $x=0;my $temp;my @crypto;my $eli;foreach $eli(@toende) {@pos=relpos($x,2,@secpass);$temp=divi(@pos);if($cho==1) {$cc=$eli-$temp;}elsif($cho==0) {$cc=$eli+$temp;}$crypto[$x]=$cc;$x++;}return(@crypto);}sub timerize {                  #Function to determinate how long the message can be readprint "Select the time of the message default:1 m(Until the end of the month)\n";print "M=End of the month\n";print "D=End of the day\n";print "H=End of the hour\n";$lim=<>;chomp($lim);my ($sec,$min,$h,$mday,$mon,$year,$wday,$yday,$isdst)=localtime();$mon+=1;$year+=1900;my @crdate=($year,$mon);if($lim =~ m/d/i){push(@crdate,$mday);print "Limit set to a day\n";}elsif($lim =~ m/h/i){push(@crdate,$mday,$h);print "Limit set to a hour\n";}else{print "Limit set to a month";}return(@crdate)}#Main, if you love calling it so...while(!($pass) || !($text)){print "Insert Pass:\n";$pass=<>;print "Insert Text:\n";$text=<>;print "To decrypt DECA\n";print "To hashing the string HASH(NOT YET)\n";print "To decrypt o crypt a text with a time limit [DECA] TIME\n";$opt=<>;chomp ($pass,$text,$opt);}@chrpass= split(//,$pass);if($opt =~ m/deca/i) {$cho=1;if($opt=~ m/time/i) {@plus=timerize();}print $plus[0]."-0-".$plus[1]."-1-".$plus[2]."-2-".$plus[3]."-3-\n";#@secpass=keygen(@chrpass,@plus);@secpass=keygen(@chrpass);@decry=split(/\|/,$text);@crypto=ende(1,@decry);#@crypto=degen(@crypto,@plus);@crypto=degen(@crypto);}else {if($opt =~ m/hash/i) {#@plus=hashing(@chrpass);$cho=2;}elsif($opt =~ m/time/i) {@plus=timerize();$cho=3;}else{@plus=();$cho=0;}#print $plus[0]."-0-".$plus[1]."-1-".$plus[2]."-2-".$plus[3]."-3-\n";#@secpass=keygen(@chrpass,@plus);@secpass=keygen(@chrpass);@chrtext= split(//,$text);#@sectext=keygen(@chrtext,@plus);@sectext=keygen(@chrtext);@crypto=ende(0,@sectext);}foreach (@crypto){                  $tofile .= $crypto[$x]."|";                  print $crypto[$x]."|";                  $x++;}if(@crypto){print "\n\nLeaving...The message has been write in out.txt\n\n 'njoy\n\n";open(OUT, ">out.txt");print OUT $tofile;close(OUT);}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.