Class: Ronin::CLI::Commands::Rot Private

Inherits:
StringProcessorCommand show all
Defined in:
lib/ronin/cli/commands/rot.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Rotates each character of data within an alphabet.

Usage

ronin rot [options] [FILE ...]

Options

-f, --file FILE                  Optional file to process
    --string STRING              Optional string to process
-M, --multiline                  Process each line separately
    --keep-newlines              Preserves newlines at the end of each line
-A, --alphabet ABC...            Alphabet characters
-n, --modulo NUM                 Number of characters to rotate (Default: 13)
-h, --help                       Print help information

Arguments

[FILE ...]                       Optional file(s) to process

Since:

  • 2.0.0

Instance Attribute Summary collapse

Attributes inherited from StringProcessorCommand

#input_values

Instance Method Summary collapse

Methods inherited from StringProcessorCommand

#print_string, #process_input, #run

Methods inherited from FileProcessorCommand

#open_file, #process_file, #process_input, #run

Constructor Details

#initialize(**kwargs) ⇒ Rot

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the ronin rot command.

Parameters:

  • kwargs (Hash{Symbol => Object})

    Additional keywords.

Since:

  • 2.0.0



88
89
90
91
92
93
# File 'lib/ronin/cli/commands/rot.rb', line 88

def initialize(**kwargs)
  super(**kwargs)

  @modulo    = 13
  @alphabets = []
end

Instance Attribute Details

#alphabetsArray<Array<String>> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The alphabets to rotate within.

Returns:

  • (Array<Array<String>>)

Since:

  • 2.0.0



80
81
82
# File 'lib/ronin/cli/commands/rot.rb', line 80

def alphabets
  @alphabets
end

#moduloInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The number of characters to rotate.

Returns:

  • (Integer)

Since:

  • 2.0.0



75
76
77
# File 'lib/ronin/cli/commands/rot.rb', line 75

def modulo
  @modulo
end

Instance Method Details

#process_string(string) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Rotates each character in the string.

Parameters:

  • string (String)

    The input string.

Returns:

  • (String)

    The rotated string.

Since:

  • 2.0.0



104
105
106
107
108
109
110
# File 'lib/ronin/cli/commands/rot.rb', line 104

def process_string(string)
  unless @alphabets.empty?
    Support::Crypto.rot(string,@modulo, alphabets: @alphabets)
  else
    Support::Crypto.rot(string,@modulo)
  end
end