]> lifelog.hopto.org Git - PerlCNF.git/commitdiff
Implemented Cocoon CNF specific NOTES ccolumn compress and encrypt with blowfish.
authorWill Budic <redacted>
Sat, 29 Nov 2025 10:54:41 +0000 (21:54 +1100)
committerWill Budic <redacted>
Sat, 29 Nov 2025 10:54:41 +0000 (21:54 +1100)
system/modules/CNF.pm
system/modules/CNFParser.pm
system/modules/Cocoon.pm

index b03b52ccb17179bb6f4be35766d79391bb7fa7e8..63166f98d3506fd5f5733f833bc04e80fdc3ebe6 100644 (file)
@@ -306,7 +306,36 @@ sub doLoadDataFile { my ($self,$e,$v)=@_;
         $self->loadDataFile($path,$e)
 }
 
-
+###
+# Perform a macro replacement on tagged strings in a property value.
+##
+sub template { my ($self, $property, %macros) = @_;
+    my $val = $self->anon($property);
+    if($val){
+       foreach my $m(keys %macros){
+           my $v = $macros{$m};
+           $m ="\\\$\\\$\\\$".$m."\\\$\\\$\\\$";
+           $val =~ s/$m/$v/gs;
+       }
+       my $prev;
+       foreach my $m(split(/\$\$\$/,$val)){
+           if(!$prev){
+               $prev = $m;
+               next;
+           }
+           undef $prev;
+           my $pv = $self->anon($m);
+           if(!$pv && exists $self->{$m}){
+               $pv =  $self->{$m}#constant($self, '$'.$m);
+           }
+           if($pv){
+               $m = "\\\$\\\$\\\$".$m."\\\$\\\$\\\$";
+               $val =~ s/$m/$pv/gs;
+           }
+       }
+       return $val;
+    }
+}
 
 ###
 # CNF Instruction tag covered reserved words.
index 49d3ad14249b118e66269980aa44f9cb0f09cda8..44f22fb9a2b724930ae87fd2489164d5fdb4cf1f 100644 (file)
@@ -433,36 +433,7 @@ sub addENVList { my ($self, @vars) = @_;
     }return;
 }
 
-###
-# Perform a macro replacement on tagged strings in a property value.
-##
-sub template { my ($self, $property, %macros) = @_;
-    my $val = $self->anon($property);
-    if($val){
-       foreach my $m(keys %macros){
-           my $v = $macros{$m};
-           $m ="\\\$\\\$\\\$".$m."\\\$\\\$\\\$";
-           $val =~ s/$m/$v/gs;
-       }
-       my $prev;
-       foreach my $m(split(/\$\$\$/,$val)){
-           if(!$prev){
-               $prev = $m;
-               next;
-           }
-           undef $prev;
-           my $pv = $self->anon($m);
-           if(!$pv && exists $self->{$m}){
-               $pv =  $self->{$m}#constant($self, '$'.$m);
-           }
-           if($pv){
-               $m = "\\\$\\\$\\\$".$m."\\\$\\\$\\\$";
-               $val =~ s/$m/$pv/gs;
-           }
-       }
-       return $val;
-    }
-}
+
 #
 #private to parser sub.
 sub doProcessCollection{ my($self,$e,$t,$v) = @_;
index c25110495ad0117d2773808cf98618c4d3c43627..52a753ded3de5b69a14544e2bbec93c4d5a44ae6 100644 (file)
@@ -3,7 +3,9 @@ use strict;
 use warnings;
 use feature qw(signatures say);
 use Crypt::CBC;
-use Crypt::Blowfish;
+use Crypt::Blowfish;#blow bubba
+use IO::Compress::Xz qw(xz $XzError) ;
+use IO::Uncompress::UnXz qw(unxz $UnXzError) ;
 
 our @DIGITS = "1234567890ABCDEFGHIJKLMWENCARCHIVE" =~ m/./g;
 our $cocoon_config = $ENV{HOME}."/.config/PerlCNF/cocoon.cnf";
@@ -22,7 +24,7 @@ sub new ($class, $key){
             -header => 'none',
             -padding => 'none',
             -nodeprecate=>1,
-            -pbkdf=>'pbkdf2'
+            -pbkdf=>'randomiv'
         )
 
     }, $class;
@@ -75,8 +77,10 @@ sub register($self, $full_name, $alias, $pass_code, $notes, $config){
     my $dref;
     my $date = CNFDateTime -> now() -> toDateTimeFormat();
     if( _passCodeCheck($pass_code) ){
-        if(!$config){
-            my $encrypted  = $self->encrypt($notes);
+        if(!$config){           
+            my $compressed;
+            my $status = xz \$notes => \$compressed  or die "xz failed: $XzError\n";
+            my $encrypted  = $self->encrypt($compressed);
             if(-f $cocoon_config){
                 $config = CNFParser ->new($cocoon_config);
                 my %dhash  = %{$config ->data()};
@@ -153,7 +157,10 @@ sub getByAliasRecord($self, $alias, $pass_code){
                 if($alias eq $row[$idx->{alias}]){
                    if($pass_code eq $row[$idx->{pass}]){
                        my $encrypted = $row[$idx->{notes}];                       
-                          $row[$idx->{notes}] = $self->decrypt($encrypted);
+                       my $decrypted = $self->decrypt($encrypted);
+                       my $unzipped;
+                       my $status = unxz \$decrypted => \$unzipped  or die "xz failed: $XzError\n";                      
+                          $row[$idx->{notes}] = $unzipped;
                        return @row;
                    }else{
                         warn "Error pass_code:$pass_code not is matching with alias:$alias";