ctf-party 1.2.1 → 1.3.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.
- checksums.yaml +4 -4
- data/lib/ctf_party.rb +1 -0
- data/lib/ctf_party/case.rb +35 -0
- data/lib/ctf_party/hex.rb +1 -1
- data/lib/ctf_party/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9053993b73413771118a0bbf7b12f5ff9c60d13a97edabdd0f473c74964cd17d
|
4
|
+
data.tar.gz: f16cad2236f81606d50398a9496eeb8e261085ad2350708217e8a85d075a6b07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9079a453c9fc080e3a43784270f156ede8cfc2607f8080578251865d64ae76ec2625c9a7540582e61c5223b3392bba39d185088b5a73c279a37e0c504bd270a
|
7
|
+
data.tar.gz: 44032d4ed1df0fbd6eef5becba5da99033c3bb9a7f3c07cc3cc69cdace61474f5b76824a58339e55423c5e592639b6bd1254031f4a87976ddb8efbbd52141eca
|
data/lib/ctf_party.rb
CHANGED
@@ -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
|
data/lib/ctf_party/hex.rb
CHANGED
data/lib/ctf_party/version.rb
CHANGED
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.
|
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
|