mirror of
https://github.com/cliffe/SecGen.git
synced 2026-02-21 11:18:06 +00:00
encoders/dna
This commit is contained in:
0
modules/encoders/cipher/dna/dna.pp
Normal file
0
modules/encoders/cipher/dna/dna.pp
Normal file
0
modules/encoders/cipher/dna/manifests/.no_puppet
Normal file
0
modules/encoders/cipher/dna/manifests/.no_puppet
Normal file
67
modules/encoders/cipher/dna/secgen_local/local.rb
Normal file
67
modules/encoders/cipher/dna/secgen_local/local.rb
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/ruby
|
||||
require_relative '../../../../../lib/objects/local_string_encoder.rb'
|
||||
class DNACipher < StringEncoder
|
||||
attr_accessor :char_map
|
||||
|
||||
def initialize
|
||||
super
|
||||
self.module_name = 'DNA Cipher Encoder'
|
||||
self.strings_to_encode = []
|
||||
self.char_map = {
|
||||
'A' => 'CGA',
|
||||
'B' => 'CCA',
|
||||
'C' => 'GTT',
|
||||
'D' => 'TTG',
|
||||
'E' => 'GGC',
|
||||
'F' => 'GGT',
|
||||
'G' => 'TTT',
|
||||
'H' => 'CGC',
|
||||
'I' => 'ATG',
|
||||
'J' => 'AGT',
|
||||
'K' => 'AAG',
|
||||
'L' => 'TGC',
|
||||
'M' => 'TCC',
|
||||
'N' => 'TCT',
|
||||
'O' => 'GGA',
|
||||
'P' => 'GTG',
|
||||
'Q' => 'AAC',
|
||||
'R' => 'TCA',
|
||||
'S' => 'ACG',
|
||||
'T' => 'TTC',
|
||||
'U' => 'CTG',
|
||||
'V' => 'CCT',
|
||||
'W' => 'CCG',
|
||||
'X' => 'CTA',
|
||||
'Y' => 'AAA',
|
||||
'Z' => 'CTT',
|
||||
' ' => 'ATA',
|
||||
',' => 'TCG',
|
||||
'.' => 'GAT',
|
||||
':' => 'GCT',
|
||||
'0' => 'ACT',
|
||||
'1' => 'ACC',
|
||||
'2' => 'TAG',
|
||||
'3' => 'GCA',
|
||||
'4' => 'GAG',
|
||||
'5' => 'AGA',
|
||||
'6' => 'TTA',
|
||||
'7' => 'ACA',
|
||||
'8' => 'AGG',
|
||||
'9' => 'GCG',
|
||||
'{' => '{',
|
||||
'}' => '}',
|
||||
'_' => '_',
|
||||
}
|
||||
end
|
||||
|
||||
def encode(str)
|
||||
encoded = []
|
||||
str.each_char do |char|
|
||||
self.char_map.key? char.upcase
|
||||
encoded << self.char_map[char.upcase]
|
||||
end
|
||||
encoded.join
|
||||
end
|
||||
end
|
||||
|
||||
DNACipher.new.run
|
||||
30
modules/encoders/cipher/dna/secgen_metadata.xml
Normal file
30
modules/encoders/cipher/dna/secgen_metadata.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<encoder xmlns="http://www.github/cliffe/SecGen/encoder"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.github/cliffe/SecGen/encoder">
|
||||
<name>DNA Cipher</name>
|
||||
<author>Thomas Shaw</author>
|
||||
<module_license>MIT</module_license>
|
||||
<description>
|
||||
</description>
|
||||
|
||||
<type>alpha_reversible</type>
|
||||
<type>dna_encoder</type>
|
||||
<type>cipher_encoder</type>
|
||||
<platform>linux</platform>
|
||||
<platform>windows</platform>
|
||||
|
||||
<reference>http://www.polestarltd.com/ttg/isspeeches/051403/slide14.jpg</reference>
|
||||
|
||||
<hint>Guanine, Adenine, Thymine and Cytosine</hint>
|
||||
<solution>http://www.polestarltd.com/ttg/isspeeches/051403/slide14.jpg</solution>
|
||||
|
||||
<read_fact>strings_to_encode</read_fact>
|
||||
|
||||
<default_input into="strings_to_encode">
|
||||
<generator type="flag_generator"/>
|
||||
</default_input>
|
||||
|
||||
<output_type>encoded_string</output_type>
|
||||
</encoder>
|
||||
Reference in New Issue
Block a user