Module: PWN::Plugins::ScannableCodes
- Defined in:
- lib/pwn/plugins/scannable_codes.rb
Overview
This plugin is used to Create Scannable BarCodes and QR Codes
Class Method Summary collapse
-
.authors ⇒ Object
- Author(s)
-
0day Inc.
-
.generate(opts = {}) ⇒ Object
- Supported Method Parameters
-
response = PWN::Plugins::ScannableCodes.generate( data: ‘required - data to encode’, type: ‘optional - :barcode || :qrcode (defaults to :qrcode)’, path: ‘optional - path to save image (defaults to “./#data.png”)’ ).
-
.help ⇒ Object
Display Usage for this Module.
Class Method Details
.authors ⇒ Object
- Author(s)
-
0day Inc. <[email protected]>
49 50 51 52 53 |
# File 'lib/pwn/plugins/scannable_codes.rb', line 49 public_class_method def self. "AUTHOR(S): 0day Inc. <[email protected]> " end |
.generate(opts = {}) ⇒ Object
- Supported Method Parameters
-
response = PWN::Plugins::ScannableCodes.generate(
data: 'required - data to encode', type: 'optional - :barcode || :qrcode (defaults to :qrcode)', path: 'optional - path to save image (defaults to "./#{data}.png")'
)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pwn/plugins/scannable_codes.rb', line 18 public_class_method def self.generate(opts = {}) data = opts[:data] raise 'ERROR: option data is required.' unless data type = opts[:type] type ||= :qrcode path = opts[:path] path ||= "./#{data}.png" case type when :barcode = Barby::Code128B.new(data) .to_png.save(path) when :qrcode qrcode = RQRCode::QRCode.new(data) png = qrcode.as_png png.resize(200, 200).save(path) else raise 'ERROR: type must be :barcode or :qrcode.' end puts "Saved #{type} to #{path}" rescue Interrupt puts "\nGoodbye." rescue StandardError => e raise e end |
.help ⇒ Object
Display Usage for this Module
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/pwn/plugins/scannable_codes.rb', line 57 public_class_method def self.help puts "USAGE: #{self}.generate( data: 'required - data to encode', type: 'optional - :barcode || :qrcode (defaults to :qrcode)', path: 'optional - path to save image (defaults to \"./\#{data}.png\")' ) #{self}.authors " end |