rotlib 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (8) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +8 -0
  3. data/bin/base16 +67 -0
  4. data/bin/rot13 +108 -0
  5. data/bin/rot47 +100 -0
  6. data/bin/url-coder +70 -0
  7. data/lib/rotlib.rb +86 -0
  8. metadata +55 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b14cd03a5a1737c45bcc2161041fed8e4c560f8207903edb4f4ee39ed07bc397
4
+ data.tar.gz: 2372a9f2b9664f8c93d99b74cecd8b61d7cafd5316b2eea5e8345570c6c0b9e8
5
+ SHA512:
6
+ metadata.gz: d563cc80555512a4532dfe9f79cbad261224e2e9a17a74cc3bb15d42849f7fe0c131eec15d691d9a59e00e176998553b37bd8e601bf27e7936b5a102579041e2
7
+ data.tar.gz: 77353006d99495db3027519963a7f36b43cde749a7593676bb5777c34804dcd75e84a77cc2cc6e92a7ebb7974b8f34dcf9be33c2b0f0f349c356d3b251a901d8
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rotlib.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/bin/base16 ADDED
@@ -0,0 +1,67 @@
1
+ #! /bin/env ruby
2
+
3
+ class Hex
4
+ attr_accessor :data
5
+ def initialize(data = $stdin.read)
6
+ @data = data
7
+ end
8
+ def toHex
9
+ $stdout.print @data.dump.bytes.map {|e| e.to_s(16)}.join
10
+ end
11
+ def fromHex
12
+ $stdout.print @data.downcase.split.pack('H*')
13
+ end
14
+ end
15
+
16
+ def main
17
+ file = ''
18
+ data = ''
19
+ encode = true
20
+ help = "base16 [-d][-h] [file]\n"
21
+ help += "hexadecimal encoder and decoder.\n"
22
+ help += " -d decode.\n\n"
23
+ help += "lib: rotlib\n"
24
+ help += "<Madhava-mng@github.com>"
25
+
26
+ ARGV.length.times do |a|
27
+ if ARGV[a].start_with? '-'
28
+ if ARGV[a] == '-d'
29
+ encode = false
30
+ else
31
+ puts help
32
+ exit
33
+ end
34
+ else
35
+ file = ARGV[a]
36
+ end
37
+ end
38
+
39
+ if file != ''
40
+ if File.file? file
41
+ File.open(file, 'r') do |f|
42
+ data += f.read
43
+ f.close
44
+ end
45
+ hex = Hex::new(data)
46
+ else
47
+ puts "base16: #{file}: No such file."
48
+ exit
49
+ end
50
+ else
51
+ hex = Hex::new
52
+ end
53
+ if encode
54
+ hex.toHex
55
+ else
56
+ hex.fromHex
57
+ end
58
+ end
59
+
60
+
61
+ begin
62
+ main
63
+ rescue Interrupt
64
+ puts "\r\e[A"
65
+ rescue => e
66
+ puts "base16 :Invalid base16(hex)"
67
+ end
data/bin/rot13 ADDED
@@ -0,0 +1,108 @@
1
+ #! /bin/env ruby
2
+ class Rot13
3
+ attr_accessor :word
4
+ def initialize(words='')
5
+ @words = words
6
+ if @words == ''
7
+ @words = $stdin.read
8
+ end
9
+ end
10
+
11
+ def rot13(iter = 13 , print_out=true)
12
+ tmp_value = ''
13
+ @words.bytes.map do |c|
14
+ if c > 64 and c < 91
15
+ c += iter
16
+ loop do
17
+ if c > 90
18
+ c = (c - 90)+64
19
+ end
20
+ break if c > 64 and c < 91
21
+ end
22
+ elsif c > 96 and c < 123
23
+ c += iter
24
+ loop do
25
+ if c > 122
26
+ c = (c - 122)+96
27
+ end
28
+ break if c > 96 and c < 123
29
+ end
30
+ end
31
+ if print_out
32
+ print c.chr
33
+ else
34
+ tmp_value += c.chr
35
+ end
36
+ end
37
+ return tmp_value
38
+ end
39
+
40
+ def rot13_log(show_max_length = 45)
41
+ if @words.length > show_max_length
42
+ @words = @words[0,show_max_length]
43
+ end
44
+ length = @words.length
45
+ 26.times do |i|
46
+ puts "#{i.to_s.rjust 2} \e[32;m>\e[0m #{rot13(i, false).dump[1, length]}"
47
+ end
48
+ end
49
+ end
50
+
51
+ def main
52
+ log = false
53
+ basic = true
54
+ rot = 13
55
+ file = ''
56
+ data = ''
57
+ help = "rot13 [-l][-r=<int>][-h] [file]\n"
58
+ help += "rot13 encoder and possibility viewer.\n"
59
+ help += " -l list all possibility with rotation.\n"
60
+ help += " -r=<int> force rotate.\n\n"
61
+ help += "lib: rotlib\n"
62
+ help += "<Madhava-mng@github.com>"
63
+
64
+ ARGV.length.times do |a|
65
+ if ARGV[a].start_with? '-'
66
+ if ARGV[a] == '-l'
67
+ log = true
68
+ basic = false
69
+ elsif ARGV[a].start_with? '-r='
70
+ rot = ARGV[a][3,ARGV[a].length].to_i
71
+ else
72
+ puts help
73
+ exit
74
+ end
75
+ else
76
+ file = ARGV[a]
77
+ end
78
+ end
79
+
80
+ if file != ''
81
+ if File.file? file
82
+ File.open(file, 'r') do |f|
83
+ data += f.read
84
+ f.close
85
+ end
86
+ rot13 = Rot13::new(data)
87
+ else
88
+ puts "rot13: #{file}: No such file"
89
+ exit
90
+ end
91
+ else
92
+ rot13 = Rot13::new
93
+ end
94
+
95
+ if basic
96
+ rot13.rot13(rot)
97
+ elsif log
98
+ rot13.rot13_log
99
+ end
100
+ end
101
+
102
+ begin
103
+ main
104
+ rescue Interrupt
105
+ puts "\r\e[A"
106
+ rescue => e
107
+ puts "rot47 :#{e}"
108
+ end
data/bin/rot47 ADDED
@@ -0,0 +1,100 @@
1
+ #! /bin/env ruby
2
+ class Rot47
3
+ attr_accessor :word
4
+ def initialize(words='')
5
+ @words = words
6
+ if @words == ''
7
+ @words = $stdin.read
8
+ end
9
+ end
10
+
11
+ def rot47(iter = 47 , print_out=true)
12
+ tmp_value = ''
13
+ @words.bytes.map do |c|
14
+ if c > 32 and c < 127
15
+ c += iter
16
+ loop do
17
+ if c > 126
18
+ c = (c - 126)+32
19
+ end
20
+ break if c > 32 and c < 127
21
+ end
22
+ end
23
+ if print_out
24
+ print c.chr
25
+ else
26
+ tmp_value += c.chr
27
+ end
28
+ end
29
+ return tmp_value
30
+ end
31
+
32
+ def rot47_log(show_max_length = 40)
33
+ if @words.length > show_max_length
34
+ @words = @words[0,show_max_length]
35
+ end
36
+ length = @words.length
37
+ 94.times do |i|
38
+ puts "#{i.to_s.rjust 2} \e[32;m>\e[0m #{rot47(i, false).dump[1, length]}"
39
+ end
40
+ end
41
+ end
42
+
43
+ def main
44
+ log = false
45
+ basic = true
46
+ rot = 47
47
+ file = ''
48
+ data = ''
49
+ help = "rot47 [-l][-r=<int>][-h] [file]\n"
50
+ help += "rot47 encoder and possibility viewer.\n"
51
+ help += " -l list all possibility with rotation.\n"
52
+ help += " -r=<int> force rotate.\n\n"
53
+ help += "lib: rotlib\n"
54
+ help += "<Madhava-mng@github.com>"
55
+
56
+ ARGV.length.times do |a|
57
+ if ARGV[a].start_with? '-'
58
+ if ARGV[a] == '-l'
59
+ log = true
60
+ basic = false
61
+ elsif ARGV[a].start_with? '-r='
62
+ rot = ARGV[a][3,ARGV[a].length].to_i
63
+ else
64
+ puts help
65
+ exit
66
+ end
67
+ else
68
+ file = ARGV[a]
69
+ end
70
+ end
71
+
72
+ if file != ''
73
+ if File.file? file
74
+ File.open(file, 'r') do |f|
75
+ data += f.read
76
+ f.close
77
+ end
78
+ rot47 = Rot47::new(data)
79
+ else
80
+ puts "rot47: #{file}: No such file"
81
+ exit
82
+ end
83
+ else
84
+ rot47 = Rot47::new
85
+ end
86
+
87
+ if basic
88
+ rot47.rot47(rot)
89
+ elsif log
90
+ rot47.rot47_log
91
+ end
92
+ end
93
+
94
+ begin
95
+ main
96
+ rescue Interrupt
97
+ puts "\r\e[A"
98
+ rescue => e
99
+ puts "rot47 :#{e}"
100
+ end
data/bin/url-coder ADDED
@@ -0,0 +1,70 @@
1
+ #! /bin/env ruby
2
+ require 'net/http'
3
+
4
+ #include URI
5
+
6
+ class UrlCoder
7
+ attr_accessor :data
8
+ def initialize(data = $stdin.read)
9
+ @data = data.chomp
10
+ end
11
+ def encode
12
+ return URI.encode_www_form_component(@data)
13
+ end
14
+ def decode
15
+ return URI::decode_www_form_component(@data)
16
+ end
17
+ end
18
+
19
+ def main
20
+ file = ''
21
+ data = ''
22
+ encode = true
23
+ help = "url-coder [-d][-h] [file]\n"
24
+ help += "url encoder and decoder.\n"
25
+ help += " -d decode.\n\n"
26
+ help += "lib: rotlib\n"
27
+ help += "<Madhava-mng@github.com>"
28
+
29
+ ARGV.length.times do |a|
30
+ if ARGV[a].start_with? '-'
31
+ if ARGV[a] == '-d'
32
+ encode = false
33
+ else
34
+ puts help
35
+ exit
36
+ end
37
+ else
38
+ file = ARGV[a]
39
+ end
40
+ end
41
+
42
+ if file != ''
43
+ if File.file? file
44
+ File.open(file, 'r') do |f|
45
+ data += f.read
46
+ f.close
47
+ end
48
+ url_encode = UrlCoder::new(data)
49
+ else
50
+ puts "url-coder: #{file}: No such file."
51
+ exit
52
+ end
53
+ else
54
+ url_encode = UrlCoder::new
55
+ end
56
+ if encode
57
+ puts url_encode.encode
58
+ else
59
+ puts url_encode.decode
60
+ end
61
+ end
62
+
63
+
64
+ begin
65
+ main
66
+ rescue Interrupt
67
+ puts "\r\e[A"
68
+ rescue => e
69
+ puts "url-coder :#{e}"
70
+ end
data/lib/rotlib.rb ADDED
@@ -0,0 +1,86 @@
1
+
2
+
3
+ require_relative "rotlib/version"
4
+ require 'net/http';
5
+
6
+ module Rotlib
7
+ def toHex(data)
8
+ return data.dump.bytes.map {|e| e.to_s(16)}.join
9
+ end
10
+ def fromHex(data)
11
+ return data.split.pack('H*')
12
+ end
13
+
14
+ def rot13(words, iter = 13)
15
+ tmp_value = ''
16
+ words.bytes.map do |c|
17
+ if c > 64 and c < 91
18
+ c += iter
19
+ loop do
20
+ if c > 90
21
+ c = (c - 90)+64
22
+ end
23
+ break if c > 64 and c < 91
24
+ end
25
+ elsif c > 96 and c < 123
26
+ c += iter
27
+ loop do
28
+ if c > 122
29
+ c = (c - 122)+96
30
+ end
31
+ break if c > 96 and c < 123
32
+ end
33
+ end
34
+ tmp_value += c.chr
35
+ end
36
+ return tmp_value
37
+ end
38
+
39
+ def rot13_log(words, show_max_length = 25)
40
+ if words.length > show_max_length
41
+ words = words.split("\n")[0]
42
+ words = words[0,show_max_length]
43
+ end
44
+ 26.times do |i|
45
+ puts "#{i.to_s.rjust 2} \e[32;m>\e[0m #{rot13(words, i)}"
46
+ end
47
+ return
48
+ end
49
+
50
+ def rot47(words, iter = 47)
51
+ tmp_value = ''
52
+ words.bytes.map do |c|
53
+ if c > 32 and c < 127
54
+ c += iter
55
+ loop do
56
+ if c > 126
57
+ c = (c - 126)+32
58
+ end
59
+ break if c > 32 and c < 127
60
+ end
61
+ end
62
+ tmp_value += c.chr
63
+ end
64
+ return tmp_value
65
+ end
66
+
67
+ def rot47_log(words, show_max_length = 25)
68
+ if words.length > show_max_length
69
+ words = words.split("\n")[0]
70
+ words = words[0,show_max_length]
71
+ end
72
+ 94.times do |i|
73
+ puts "#{i.to_s.rjust 2} \e[32;m>\e[0m #{rot47(words, i)}"
74
+ end
75
+ return
76
+ end
77
+
78
+ def url_encode(url2encode)
79
+ return URI.encode_www_form_component(url2encode)
80
+ end
81
+ def url_decode(url2decode)
82
+ return URI::decode_www_form_component(url2decode)
83
+ end
84
+ end
85
+
86
+ include Rotlib
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rotlib
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Madhava-mng
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-06-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: ''
14
+ email:
15
+ - usermail@owbdu3bdowje.onion
16
+ executables:
17
+ - base16
18
+ - rot13
19
+ - rot47
20
+ - url-coder
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - Gemfile
25
+ - bin/base16
26
+ - bin/rot13
27
+ - bin/rot47
28
+ - bin/url-coder
29
+ - lib/rotlib.rb
30
+ homepage: https://github.com/Madhava-mng/rotlib-ruby
31
+ licenses:
32
+ - MIT
33
+ metadata:
34
+ allowed_push_host: https://rubygems.org
35
+ homepage_uri: https://github.com/Madhava-mng/rotlib-ruby
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 2.4.0
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubygems_version: 3.2.15
52
+ signing_key:
53
+ specification_version: 4
54
+ summary: Rotlib is rot13,rot47,hex,url.. encoding and rot debugger.
55
+ test_files: []