Things I do when I'm bored or avoiding work...

only an hour to wait for the 120meg file of the human gnome to down load. Now the question is, if words were to actually show up, what language do we think it would show up in? Americanised English is of course the default to try since it is my native. I'm thinking that if anything has a chance of being there, it would either be one of the ancient, likely dead languages. Maybe it will just be the sounds of all the languages. I remember one a Discover/TLC program where a theory was given that humans are born able to make all the sounds of all the human languages on the planet and what sounds the baby remembers and makes are based on which of the language sounds it hears regularly.
 
hmmm .. instead of letters, wonder if I should look for simple math functions.
 
Any suduko addicts here who are into cryptanalysis? Looking for useful resources to play with my dna decrypt, it hit me that the suduko grid kinda screams 'block cypher'.
 
linuxgeek said:
Input:
This is a test of the DNA encoding system. This is only a test. It would only be a real emergency if the geek was trying to create life.


hee hee :)
 
linuxgeek said:
only an hour to wait for the 120meg file of the human gnome to down load. Now the question is, if words were to actually show up, what language do we think it would show up in? Americanised English is of course the default to try since it is my native. I'm thinking that if anything has a chance of being there, it would either be one of the ancient, likely dead languages. Maybe it will just be the sounds of all the languages. I remember one a Discover/TLC program where a theory was given that humans are born able to make all the sounds of all the human languages on the planet and what sounds the baby remembers and makes are based on which of the language sounds it hears regularly.

i now hand over to you any claims of geek royalty i may have

-curtsies to your highness-
 
Hester said:
i now hand over to you any claims of geek royalty i may have

-curtsies to your highness-

What? That wasn't nearly that geeky. However, that I am current rewritting the perl code I started this thread with so that it uses all the possible ACGT x 4 combinations may put me in the running.
 
Ok, I feel better now.
Code:
#!/usr/bin/perl

# ###############################################################
# DNA sequence decoding/encoding -- version 2
# ###############################################################

@alphabet = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
             '0','1','2','3','4','5','6','7','8','9','.','!','?',' ','@','#','$','%','*','(',')','-','+','=','/',':',';',',',"\n",
             'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
            );
%encrypt = ();
%decrypt = ();

# #############
# Main
# #############

  if ( $#ARGV < 0 ) {
    print 'USAGE: dna2.pl <e|d> [<text>] or dna2.pl <e|d> < <file>' . "\n";
    exit;
    }

  if ( ( $ARGV[0] eq 'e' ) || ( $ARGV[0] eq 'E' ) ) {
    $crypting=0;
    }
  elsif ( ( $ARGV[0] eq 'd' ) || ( $ARGV[0] eq 'D' ) ) {
    $crypting=1;
    }
  else {
    print 'you need to select whether to <e>ncrypt or <d>crypt' . "\n";
    exit;
    }

  CreateEHash();
  CreateDHash();

  if ( $#ARGV < 1 ) {
     while (<STDIN>) {

        if ( $crypting == 1 ) {
          for ( $i=0 ; $i < length($_) ;  $i+=4 ) {
             Decrypt(substr($_,$i,4));
             }
          }
        else {
          for ( $i=0 ; $i < length($_) ; $i++ ) {
             Encrypt(substr($_,$i,1));
             }
          }
        }
     }

  if ( $#ARGV >= 1 ) {
     @args = @ARGV[1..$#ARGV];
     $line = sprintf join(" ",@args);

     if ( $crypting == 1) {
       for ( $i=0 ; $i < length($line) ;  $i+=4 ) {
          Decrypt(substr($line,$i,4));
          }
       }
     else {
       for ( $i=0 ; $i < length($line) ; $i++ ) {
          Encrypt(substr($line,$i,1));
          }
       }
     }

  print "\n";

# ###################
# create encrypt hash
# ###################

sub CreateEHash {
  $idx=0;

  for ( $p4=0 ; $p4 < 4 ; $p4++ ) {
     for ( $p3=0 ; $p3 < 4 ; $p3++ ) {
        for ( $p2=0 ; $p2 < 4 ; $p2++ ) {
           for ( $p1=0 ; $p1 < 4 ; $p1++ ) {

              if  ( $idx <= $#alphabet ) {
                 $DNA = ACGT($p1) . ACGT($p2) . ACGT($p3) . ACGT($p4);
                 $encrypt{$alphabet[$idx]} = $DNA;
                 $idx++;
                 }
              }
           }
        }
     }
  }

# ###################
# create decrypt hash
# ###################

sub CreateDHash {

  foreach $key (keys %encrypt) {
    $decrypt{$encrypt{$key}} = $key;
    }

  }

# ###################
# create decrypt hash
# ###################

sub Encrypt($) {

  print $encrypt{@_[0]};

  }

# ###################
# create decrypt hash
# ###################

sub Decrypt($) {

  print $decrypt{@_[0]};

  }

# ######################
# create DNA ACGT output
# ######################

sub ACGT($) {


  if ( @_[0] == 0 ) {
    return 'A';
    }

  if ( @_[0] == 1 ) {
    return 'C';
    }

  if ( @_[0] == 2 ) {
    return 'G';
    }

  if ( @_[0] == 3 ) {
    return 'T';
    }

  }

In:
What do you want to do tonight, Brain? Same thing we do every night, Pinky. Try to take over the world!


Out:
GCCAGTTATCTAGGACTCGAGGTACCACTCGATTACCCACTGACTCGACTACTCTAACACGGACTCGAGGACCCACTCGAGGTACCACTCGAGGACCCACACACTTTACTTAGTTAGGACCCTATCGACAAAAGACTCTATTTAACACGCGATCGAGACATCTATAACTGTATCGAGGACGTTATTTAACACCTTATCGACTACTGTATCGAGGTACCACTCGATGTAATACTGTAAGACTTACTCGAACACTTTACTTAGTTAGGACCCTATCGATTAATTTAACACCAACTTACACGATCGATACAAGACTTACTCGAGGACCCACTCGAGGACTCTACAACTGTATCGACCACATACTGTAAGACTCGAGGACGTTATGTATCGACTACCCACAGACGAACGGTACCGA
 
ha ha... now I have made it more Enigma like ... each charater has at least 3 different codes it can encode to. Will at least defeat basic statistial analysis.

Code:
#!/usr/bin/perl

# ###############################################################
# DNA sequence decoding/encoding -- version 2.1
# ###############################################################

@alphabet = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
             '0','1','2','3','4','5','6','7','8','9','.','!','?',' ','@','#','$','%','*','(',')','-','+','=','/',':',';',',',"\n",
             'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
            );
%encrypt1 = ();
%encrypt2 = ();
%encrypt3 = ();
%encrypt4 = ();
%decrypt = ();

# #############
# Main
# #############

  if ( $#ARGV < 0 ) {
    print 'USAGE: dna2.pl <e|d> [<text>] or dna2.pl <e|d> < <file>' . "\n";
    exit;
    }

  if ( ( $ARGV[0] eq 'e' ) || ( $ARGV[0] eq 'E' ) ) {
    $crypting=0;
    }
  elsif ( ( $ARGV[0] eq 'd' ) || ( $ARGV[0] eq 'D' ) ) {
    $crypting=1;
    }
  else {
    print 'you need to select whether to <e>ncrypt or <d>crypt' . "\n";
    exit;
    }

  CreateEHash();
  CreateDHash();

  if ( $#ARGV < 1 ) {
     while (<STDIN>) {

        if ( $crypting == 1 ) {
          for ( $i=0 ; $i < length($_) ;  $i+=4 ) {
             Decrypt(substr($_,$i,4));
             }
          }
        else {
          for ( $i=0 ; $i < length($_) ; $i++ ) {
             Encrypt(substr($_,$i,1));
             }
          }
        }
     }

  if ( $#ARGV >= 1 ) {
     @args = @ARGV[1..$#ARGV];
     $line = sprintf join(" ",@args);

     if ( $crypting == 1) {
       for ( $i=0 ; $i < length($line) ;  $i+=4 ) {
          Decrypt(substr($line,$i,4));
          }
       }
     else {
       for ( $i=0 ; $i < length($line) ; $i++ ) {
          Encrypt(substr($line,$i,1));
          }
       }
     }

  print "\n";

# ###################
# create encrypt hash
# ###################

sub CreateEHash {
  $idx=0;
  $hash=0;
  $total=0;

  for ( $p4=0 ; $p4 < 4 ; $p4++ ) {
     for ( $p3=0 ; $p3 < 4 ; $p3++ ) {
        for ( $p2=0 ; $p2 < 4 ; $p2++ ) {
           for ( $p1=0 ; $p1 < 4 ; $p1++ ) {

              if ( ( $idx <= $#alphabet ) && ( $hash == 0 ) ) {
                 $DNA = ACGT($p1) . ACGT($p2) . ACGT($p3) . ACGT($p4);
                 $encrypt1{$alphabet[$idx]} = $DNA;
                 $idx++;
                 }
              elsif ( ( $idx > $#alphabet ) && ( $hash == 0 ) ) {
                 $hash++;
                 $idx=0;
                 }

              if ( ( $idx <= $#alphabet ) && ( $hash == 1 ) ) {
                 $DNA = ACGT($p1) . ACGT($p2) . ACGT($p3) . ACGT($p4);
                 $encrypt2{$alphabet[$idx]} = $DNA;
                 $idx++;
                 }
              elsif ( ( $idx > $#alphabet ) && ( $hash == 1 ) ) {
                 $hash++;
                 $idx=0;
                 }

              if ( ( $idx <= $#alphabet ) && ( $hash == 2) ) {
                 $DNA = ACGT($p1) . ACGT($p2) . ACGT($p3) . ACGT($p4);
                 $encrypt3{$alphabet[$idx]} = $DNA;
                 $idx++;
                 }
              elsif ( ( $idx > $#alphabet ) && ( $hash == 2 ) ) {
                 $hash++;
                 $idx=0;
                 }

              if ( ( $idx <= $#alphabet ) && ( $hash == 3) ) {
                 $DNA = ACGT($p1) . ACGT($p2) . ACGT($p3) . ACGT($p4);
                 $encrypt4{$alphabet[$idx]} = $DNA;
                 $idx++;
                 }

              }
           }
        }
     }
  }

# ###################
# create decrypt hash
# ###################

sub CreateDHash {

  foreach $key (keys %encrypt1) {
    $decrypt{$encrypt1{$key}} = $key;
    }

  foreach $key (keys %encrypt2) {
    $decrypt{$encrypt2{$key}} = $key;
    }

  foreach $key (keys %encrypt3) {
    $decrypt{$encrypt3{$key}} = $key;
    }

  foreach $key (keys %encrypt4) {
    $decrypt{$encrypt4{$key}} = $key;
    }
  }

# ###################
# create decrypt hash
# ###################

sub Encrypt($) {

  $hash=int(rand(4));

  if ( $hash == 0) {
     print $encrypt1{@_[0]};
     }

  if ( $hash == 1) {
     print $encrypt2{@_[0]};
     }

  if ( $hash == 2) {
     print $encrypt3{@_[0]};
     }

  if ( $hash == 3) {
     if ( exists($encrypt4{@_[0]}) ) {
        print $encrypt4{@_[0]};
        }
     else {
        $hash=int(rand(3));

        if ( $hash == 0) {
           print $encrypt1{@_[0]};
           }

        if ( $hash == 1) {
           print $encrypt2{@_[0]};
           }

        if ( $hash == 2) {
           print $encrypt3{@_[0]};
           }
        }
     }
  }

# ###################
# create decrypt hash
# ###################

sub Decrypt($) {

  print $decrypt{@_[0]};

  }

# ######################
# create DNA ACGT output
# ######################

sub ACGT($) {


  if ( @_[0] == 0 ) {
    return 'A';
    }

  if ( @_[0] == 1 ) {
    return 'C';
    }

  if ( @_[0] == 2 ) {
    return 'G';
    }

  if ( @_[0] == 3 ) {
    return 'T';
    }

  }
Input:
aaaabbbbccccddddeeee

Output:
CGCTTCTAAGAGCGCTGGCTGGCTGGCTGGCTGGAGGGAGTGCTCGTAATCTATCTTGAGGGTATGTATGTACTCTATAG
 
So what is everyone else doing in leu of working @ work in this week before Xmas? How much less productive do you plan to be between Xmas & New years?
 
Back
Top