ctf-party 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3320dd66b3b305ed07cce2d8e9059f83f5c6c65b763401223af57d157bcbffb4
4
- data.tar.gz: 4ae59e35eb39beb3641cfa9e5d22609f93e18b9540884876d3982ab4ab7cc97e
3
+ metadata.gz: 9053993b73413771118a0bbf7b12f5ff9c60d13a97edabdd0f473c74964cd17d
4
+ data.tar.gz: f16cad2236f81606d50398a9496eeb8e261085ad2350708217e8a85d075a6b07
5
5
  SHA512:
6
- metadata.gz: 72c0b492360e7a52af7e3abe000c275accc183f28ea3ca9753fdc92e43258abc45967cb0aa79448ebdcbd118d65aba33435c37354ba0595a0f3459d591b4d37b
7
- data.tar.gz: '0907211c7da78180930cfb8243169ae4bb3f63515fa3fd1538b576fa11f34e3278796c757dd494b6f206bca0b6dd09bda2e0308b7e3f42713cf40410e279e3b2'
6
+ metadata.gz: f9079a453c9fc080e3a43784270f156ede8cfc2607f8080578251865d64ae76ec2625c9a7540582e61c5223b3392bba39d185088b5a73c279a37e0c504bd270a
7
+ data.tar.gz: 44032d4ed1df0fbd6eef5becba5da99033c3bb9a7f3c07cc3cc69cdace61474f5b76824a58339e55423c5e592639b6bd1254031f4a87976ddb8efbbd52141eca
@@ -6,3 +6,4 @@ require 'ctf_party/rot'
6
6
  require 'ctf_party/digest'
7
7
  require 'ctf_party/flag'
8
8
  require 'ctf_party/hex'
9
+ require 'ctf_party/case'
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ class String
4
+ # Change the case of characters randomly
5
+ # @return [String] the case modified string
6
+ # @example
7
+ # 'SELECT * FROM'.randomcase # => "SElECt * frOm"
8
+ # 'SELECT * FROM'.randomcase # => "selECT * FROm"
9
+ def randomcase
10
+ chars.map { |c| rand(0..1).zero? ? c.downcase : c.upcase }.join
11
+ end
12
+
13
+ # Change the case of characters randomly in place as described for
14
+ # {String#randomcase}.
15
+ def randomcase!
16
+ replace(randomcase)
17
+ end
18
+
19
+ # Change one characte on two upcase and the other downcase
20
+ # @param shift [Integer] 0: 1st character will be downcase, 1: 1st character
21
+ # will be upcase
22
+ # @return [String] the case modified string
23
+ # @example
24
+ # 'SELECT * FROM'.alternatecase # => "sElEcT * FrOm"
25
+ # 'SELECT * FROM'.alternatecase(1) # => "SeLeCt * fRoM"
26
+ def alternatecase(shift = 0)
27
+ chars.each_with_index.map { |c, i| (i + shift).even? ? c.downcase : c.upcase }.join
28
+ end
29
+
30
+ # Change one characte on two upcase and the other downcase in place as
31
+ # described for {String#alternatecase}.
32
+ def alternatecase!(shift = 0)
33
+ replace(alternatecase(shift))
34
+ end
35
+ end
@@ -22,7 +22,7 @@ class String
22
22
  # @example
23
23
  # a = 'ff'
24
24
  # a.hex2dec!
25
- # a # => => "255"
25
+ # a # => "255"
26
26
  def hex2dec!(opts = {})
27
27
  replace(hex2dec(opts))
28
28
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Version
4
- VERSION = '1.2.1'
4
+ VERSION = '1.3.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ctf-party
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre ZANNI
@@ -135,6 +135,7 @@ files:
135
135
  - bin/ctf_party_console
136
136
  - lib/ctf_party.rb
137
137
  - lib/ctf_party/base64.rb
138
+ - lib/ctf_party/case.rb
138
139
  - lib/ctf_party/digest.rb
139
140
  - lib/ctf_party/flag.rb
140
141
  - lib/ctf_party/hex.rb