File: payload_generator.rb

package info (click to toggle)
ruby-stomp 1.4.10-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 832 kB
  • sloc: ruby: 8,595; sh: 77; makefile: 3
file content (32 lines) | stat: -rw-r--r-- 506 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- encoding: utf-8 -*-

class PayloadGenerator

  private

  @@BSTRING = ""

  public

  def self.initialize(min = 1, max = 4096)
    srand()
    #
    @@min, @@max = min, max
    if @@min > @@max
      @@min, @@max = @@max, @@min
      warn "Swapping min and max values"
    end
    #
    @@BSTRING = "9" * @@max
    nil
  end # of initialize

  def self.payload
    i = rand(@@max - @@min)
    i = 1 if i == 0
    i += @@min 
    # puts "DBI: #{i}"
    @@BSTRING.byteslice(0, i)
  end

end # of class