Sha256: d328d48902d5fa6448bcf819840a45cb323fa79354819fc3ca70696662be2b49

Contents?: true

Size: 648 Bytes

Versions: 1

Compression:

Stored size: 648 Bytes

Contents

class Rot

  attr_accessor :mappings, :unknown_mapping, :encryption_tokenizer, :decryption_tokenizer

  def initialize mappings, unknown_mapping, encryption_tokenizer, decryption_tokenizer
    @mappings                   = mappings
    @unknown_mapping            = unknown_mapping
    @encryption_tokenizer       = encryption_tokenizer
    @decryption_tokenizer       = decryption_tokenizer
  end

  def decrypt word
    word.scan(@decryption_tokenizer).map { |char| @mappings[char] || @unknown_mapping } * ''
  end

  def encrypt word
    word.scan(@encryption_tokenizer).map { |char| @mappings.invert[char] || @unknown_mapping } * ''
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rot-0.2.0 lib/rot.rb