opensecret 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/README.md +2 -2
- data/bin/opensecret +3 -6
- data/lib/opensecret-domain.ini +23 -0
- data/lib/opensecret.rb +30 -2
- data/lib/opensecret/additions/array.rb +117 -0
- data/lib/opensecret/additions/dir.rb +35 -0
- data/lib/opensecret/additions/string.rb +312 -0
- data/lib/opensecret/commons/eco.cmdline.rb +446 -0
- data/lib/opensecret/commons/eco.faculty.rb +364 -0
- data/lib/opensecret/commons/eco.system.rb +437 -0
- data/lib/opensecret/commons/eco.systems.rb +98 -0
- data/lib/opensecret/{safe.rb → delegate.rb} +4 -2
- data/lib/opensecret/eco.do.rb +46 -0
- data/lib/opensecret/executors/crypt.keys/crypt.keys.ini +79 -0
- data/lib/opensecret/executors/crypt.keys/crypt.keys.rb +68 -0
- data/lib/opensecret/executors/decrypt/decrypt.ini +64 -0
- data/lib/opensecret/executors/decrypt/decrypt.rb +49 -0
- data/lib/opensecret/executors/encrypt/encrypt.ini +55 -0
- data/lib/opensecret/executors/encrypt/encrypt.rb +82 -0
- data/lib/opensecret/factbase/hub-runtime.ini +123 -0
- data/lib/opensecret/factbase/known-hosts.ini +75 -0
- data/lib/opensecret/factbase/published.facts/blobbolicious-facts.ini +553 -0
- data/lib/opensecret/factbase/published.facts/credential-facts.ini +40 -0
- data/lib/opensecret/factbase/published.facts/infrastructure-facts.ini +63 -0
- data/lib/opensecret/factbase/readme.md +24 -0
- data/lib/opensecret/factbase/retired.facts/maven.database.ide.facts.ini +127 -0
- data/lib/opensecret/factbase/retired.facts/s3-upload-block-facts.ini +17 -0
- data/lib/opensecret/plugins.io/cipher/crypto.rb +174 -0
- data/lib/opensecret/plugins.io/error/eco.exceptions.rb +24 -0
- data/lib/opensecret/plugins.io/facts/fact.chars.rb +66 -0
- data/lib/opensecret/plugins.io/facts/fact.factor.rb +156 -0
- data/lib/opensecret/plugins.io/facts/fact.locator.rb +105 -0
- data/lib/opensecret/plugins.io/facts/fact.reader.rb +137 -0
- data/lib/opensecret/plugins.io/facts/fact.tree.rb +661 -0
- data/lib/opensecret/plugins.io/file/file.rb +483 -0
- data/lib/opensecret/plugins.io/git/git.flow.rb +388 -0
- data/lib/opensecret/plugins.io/logs/log.object.rb +89 -0
- data/lib/opensecret/plugins.io/logs/logging.rb +203 -0
- data/lib/opensecret/plugins.io/time/time.stamp.rb +425 -0
- data/lib/opensecret/version.rb +2 -2
- data/opensecret.gemspec +8 -13
- metadata +68 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0d63e217092bc721ad94dfb5ae966875a9fd17d
|
4
|
+
data.tar.gz: 87eff49362703bb87775686c8976398deeeb80f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66f8e8cc37da72a39d075b0e89e7786e4d6499212e165c60b8e66ad014418c8905277e478c743d4f138ee3d5396c30e52afa7f165cf3763c82e8540220efca66
|
7
|
+
data.tar.gz: 467e06826f0d175f88f50510da1f6c5c9dca4e5025c3da0f354bb29da5cef6277a8ef58fa92bd47090ab0f25ae2b3a2b5d6de06f99ff4b16147234b5be5ec687
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# OpenSecret
|
2
2
|
|
3
3
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/opensecret`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
4
|
|
@@ -40,4 +40,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
40
40
|
|
41
41
|
## Code of Conduct
|
42
42
|
|
43
|
-
Everyone interacting in the
|
43
|
+
Everyone interacting in the OpenSecret project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/opensecret/blob/master/CODE_OF_CONDUCT.md).
|
data/bin/opensecret
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
opensecret configure mode="secure"
|
7
|
+
opensecret configure mode="secure"
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
[@[os|domain.id]]
|
13
|
+
|
14
|
+
secrecy = play # Options are play | secure | enterprise see website for details.
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
[people]
|
19
|
+
|
20
|
+
jack = jackhiggins@blueyonder.com
|
21
|
+
gaz = gareth.southgate@gmail.com
|
22
|
+
jiji = johnjames23@yahoo.co.uk
|
23
|
+
|
data/lib/opensecret.rb
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
require "opensecret/version"
|
2
|
+
require "thor"
|
3
|
+
|
4
|
+
module OpenSecret
|
5
|
+
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
#
|
10
|
+
# This command line processor will
|
11
|
+
#
|
12
|
+
# - read the posted commands, options and switches
|
13
|
+
# - maps the incoming string data to objects
|
14
|
+
# - assert that the mandatory options exist
|
15
|
+
# - assert the type of each parameter
|
16
|
+
# - ensure that the parameter values are in range
|
17
|
+
# - delegate processing to the registered handlers
|
18
|
+
#
|
19
|
+
# @note the Thor ruby gem is used for the heavy lifting
|
20
|
+
#
|
21
|
+
class CommandProcessor < Thor
|
22
|
+
|
23
|
+
# opensecret init lecturers@cambridge.university
|
24
|
+
|
25
|
+
desc "init DOMAIN", "DOMAIN identifies your team, friends, family or business."
|
26
|
+
def init( domain )
|
27
|
+
|
28
|
+
puts "You want to create the #{domain} domain.\n"
|
29
|
+
return "goodbye"
|
30
|
+
|
31
|
+
end
|
2
32
|
|
3
|
-
module Opensecret
|
4
|
-
# Your code goes here...
|
5
33
|
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# --
|
4
|
+
# -- Reopen the core ruby Array class and add the below methods to it.
|
5
|
+
# --
|
6
|
+
# -- Case Sensitivity rules for [ALL] the below methods that are
|
7
|
+
# -- added to the core Ruby string class.
|
8
|
+
# --
|
9
|
+
# -- For case insensitive behaviour make sure you downcase both the
|
10
|
+
# -- string object and the parameter strings (or strings within
|
11
|
+
# -- other parameter objects, like arrays and hashes).
|
12
|
+
# --
|
13
|
+
class Array
|
14
|
+
|
15
|
+
# --
|
16
|
+
# -- Get the text [in between] this and that delimeter [exclusively].
|
17
|
+
# -- Exclusively means the returned text [does not] include either of
|
18
|
+
# -- the matched delimeters (although an unmatched instance of [this]
|
19
|
+
# -- delimeter may appear in the in-between text).
|
20
|
+
# --
|
21
|
+
# -- --------------------
|
22
|
+
# -- Multiple Delimiters
|
23
|
+
# -- --------------------
|
24
|
+
# --
|
25
|
+
# -- When multiple delimiters exist, the text returned is in between the
|
26
|
+
# --
|
27
|
+
# -- [a] - first occurrence of [this] delimeter AND the
|
28
|
+
# -- [b] - 1st occurrence of [that] delimeter [AFTER] the 1st delimiter
|
29
|
+
# --
|
30
|
+
# -- Instances of [that] delimiter occurring before [this] are ignored.
|
31
|
+
# -- The text could contain [this] delimeter instances but is guaranteed
|
32
|
+
# -- not to contain a [that] delimeter.
|
33
|
+
# --
|
34
|
+
# -- -----------
|
35
|
+
# -- Parameters
|
36
|
+
# -- -----------
|
37
|
+
# --
|
38
|
+
# -- this_delimiter : begin delimeter (not included in returned string)
|
39
|
+
# -- that_delimiter : end delimeter (not included in returned string)
|
40
|
+
# --
|
41
|
+
# -- -----------
|
42
|
+
# -- Exceptions
|
43
|
+
# -- -----------
|
44
|
+
# --
|
45
|
+
# -- An exception (error) will be thrown if
|
46
|
+
# --
|
47
|
+
# -- => any nil (or empties) exist in the input parameters
|
48
|
+
# -- => [this] delimeter does not appear in the in_string
|
49
|
+
# -- => [that] delimeter does not appear after [this] one
|
50
|
+
# --
|
51
|
+
def before_and_after begin_delimeter, end_delimeter
|
52
|
+
|
53
|
+
Throw.if_nil_or_empty_strings [ self, begin_delimeter, end_delimeter ]
|
54
|
+
|
55
|
+
before_after_lines = []
|
56
|
+
in_middle_bit = false
|
57
|
+
|
58
|
+
self.each do |candidate_line|
|
59
|
+
|
60
|
+
is_middle_boundary = !in_middle_bit && candidate_line.downcase.include?(begin_delimeter.downcase)
|
61
|
+
if is_middle_boundary
|
62
|
+
in_middle_bit = true
|
63
|
+
next
|
64
|
+
end
|
65
|
+
|
66
|
+
unless in_middle_bit
|
67
|
+
before_after_lines.push candidate_line
|
68
|
+
next
|
69
|
+
end
|
70
|
+
|
71
|
+
#--
|
72
|
+
#-- Now we are definitely in the middle bit.
|
73
|
+
#-- Let's check for the middle end delimeter
|
74
|
+
#--
|
75
|
+
if candidate_line.downcase.include? end_delimeter.downcase
|
76
|
+
in_middle_bit = false
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
return before_after_lines
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
def middlle_bit begin_delimeter, end_delimeter
|
87
|
+
|
88
|
+
Throw.if_nil_or_empty_strings [ self, begin_delimeter, end_delimeter ]
|
89
|
+
|
90
|
+
middle_lines = []
|
91
|
+
in_middle_bit = false
|
92
|
+
|
93
|
+
self.each do |candidate_line|
|
94
|
+
|
95
|
+
is_middle_boundary = !in_middle_bit && candidate_line.downcase.include?(begin_delimeter.downcase)
|
96
|
+
if is_middle_boundary
|
97
|
+
in_middle_bit = true
|
98
|
+
next
|
99
|
+
end
|
100
|
+
|
101
|
+
end_of_middle = in_middle_bit && candidate_line.downcase.include?(end_delimeter.downcase)
|
102
|
+
return middle_lines if end_of_middle
|
103
|
+
|
104
|
+
#--
|
105
|
+
#-- We are definitely in the middle bit.
|
106
|
+
#--
|
107
|
+
middle_lines.push(candidate_line) if in_middle_bit
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
unreachable_str = "This point should be unreachable unless facts are ended."
|
112
|
+
raise RuntimeError.new unreachable_str
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# --
|
4
|
+
# -- Reopen the core ruby Dirctory class and add the below methods to it.
|
5
|
+
# --
|
6
|
+
class Dir
|
7
|
+
|
8
|
+
# --
|
9
|
+
# -- Put all the files starting with the given string in
|
10
|
+
# -- alphabetical ascending order and then return the file
|
11
|
+
# -- that comes last.
|
12
|
+
# --
|
13
|
+
# -- Throw an exception if no file in this folder starts
|
14
|
+
# -- with the given string
|
15
|
+
# --
|
16
|
+
def ascii_order_file_starting_with starts_with_string
|
17
|
+
|
18
|
+
recently_added_file = nil
|
19
|
+
filepath_leadstr = File.join self.path, starts_with_string
|
20
|
+
Dir.glob("#{filepath_leadstr}*").sort.each do |candidate_file|
|
21
|
+
|
22
|
+
next if File.directory? candidate_file
|
23
|
+
recently_added_file = candidate_file
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
Throw.if_nil recently_added_file
|
28
|
+
Throw.if_not_exists recently_added_file
|
29
|
+
return recently_added_file
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,312 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# --
|
4
|
+
# -- Reopen the core ruby String class and add the below methods to it.
|
5
|
+
# --
|
6
|
+
# -- Case Sensitivity rules for [ALL] the below methods that are
|
7
|
+
# -- added to the core Ruby string class.
|
8
|
+
# --
|
9
|
+
# -- For case insensitive behaviour make sure you downcase both the
|
10
|
+
# -- string object and the parameter strings (or strings within
|
11
|
+
# -- other parameter objects, like arrays and hashes).
|
12
|
+
# --
|
13
|
+
class String
|
14
|
+
|
15
|
+
# --
|
16
|
+
# -- Get the text [in between] this and that delimeter [exclusively].
|
17
|
+
# -- Exclusively means the returned text [does not] include either of
|
18
|
+
# -- the matched delimeters (although an unmatched instance of [this]
|
19
|
+
# -- delimeter may appear in the in-between text).
|
20
|
+
# --
|
21
|
+
# -- --------------------
|
22
|
+
# -- Multiple Delimiters
|
23
|
+
# -- --------------------
|
24
|
+
# --
|
25
|
+
# -- When multiple delimiters exist, the text returned is in between the
|
26
|
+
# --
|
27
|
+
# -- [a] - first occurrence of [this] delimeter AND the
|
28
|
+
# -- [b] - 1st occurrence of [that] delimeter [AFTER] the 1st delimiter
|
29
|
+
# --
|
30
|
+
# -- Instances of [that] delimiter occurring before [this] are ignored.
|
31
|
+
# -- The text could contain [this] delimeter instances but is guaranteed
|
32
|
+
# -- not to contain a [that] delimeter.
|
33
|
+
# --
|
34
|
+
# -- -----------
|
35
|
+
# -- Parameters
|
36
|
+
# -- -----------
|
37
|
+
# --
|
38
|
+
# -- this_delimiter : begin delimeter (not included in returned string)
|
39
|
+
# -- that_delimiter : end delimeter (not included in returned string)
|
40
|
+
# --
|
41
|
+
# -- -----------
|
42
|
+
# -- Exceptions
|
43
|
+
# -- -----------
|
44
|
+
# --
|
45
|
+
# -- An exception (error) will be thrown if
|
46
|
+
# --
|
47
|
+
# -- => any nil (or empties) exist in the input parameters
|
48
|
+
# -- => [this] delimeter does not appear in the in_string
|
49
|
+
# -- => [that] delimeter does not appear after [this] one
|
50
|
+
# --
|
51
|
+
def in_between this_delimeter, that_delimeter
|
52
|
+
|
53
|
+
Throw.if_nil_or_empty_strings [ self, this_delimeter, that_delimeter ]
|
54
|
+
|
55
|
+
scanner_1 = StringScanner.new self
|
56
|
+
scanner_1.scan_until /#{this_delimeter}/
|
57
|
+
scanner_2 = StringScanner.new scanner_1.post_match
|
58
|
+
scanner_2.scan_until /#{that_delimeter}/
|
59
|
+
|
60
|
+
in_between_text = scanner_2.pre_match.strip
|
61
|
+
log.info(ere){ in_between_text }
|
62
|
+
|
63
|
+
return in_between_text
|
64
|
+
|
65
|
+
# --> file_text = File.read "c:/Users/apollo13/mirror.techwiki/documents/collaboration-tech/gollum/gollum-certbot-ssl.md"
|
66
|
+
|
67
|
+
# --> this_delimeter = "<!-- facts"
|
68
|
+
# --> that_delimeter = "-->"
|
69
|
+
|
70
|
+
# --> scanner = StringScanner.new file_text
|
71
|
+
# --> log.info(ere){ "1st Delimiter => #{this_delimeter}" }
|
72
|
+
# --> log.info(ere){ "2nd Delimiter => #{that_delimeter}" }
|
73
|
+
# --> before_text = scanner.scan_until /#{this_delimeter}/
|
74
|
+
# --> post_match_text = scanner.post_match
|
75
|
+
# --> scanner2 = StringScanner.new post_match_text
|
76
|
+
# --> scanner2.scan_until /#{that_delimeter}/
|
77
|
+
# --> best_text = scanner2.pre_match.strip
|
78
|
+
|
79
|
+
# --> best_text = Strings.in_between file_text, this_delimeter, that_delimeter
|
80
|
+
|
81
|
+
# --> log.info(ere){ "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" }
|
82
|
+
# --> log.info(ere){ "What We Want" }
|
83
|
+
# --> log.info(ere){ "======================================================" }
|
84
|
+
# --> log.info(ere){ best_text }
|
85
|
+
# --> log.info(ere){ "======================================================" }
|
86
|
+
|
87
|
+
# --> exit
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
# --
|
93
|
+
# -- Return true if the [little string] within this
|
94
|
+
# -- string object is both
|
95
|
+
# --
|
96
|
+
# -- a] topped by the parameter prefix AND
|
97
|
+
# -- b] tailed by the parameter postfix
|
98
|
+
# --
|
99
|
+
# -- -----------------------------------------
|
100
|
+
# -- In the below example [true] is returned
|
101
|
+
# -- -----------------------------------------
|
102
|
+
# --
|
103
|
+
# -- This [String] => "Hey [<-secrets->] are juicy."
|
104
|
+
# -- little string => "secrets"
|
105
|
+
# -- topped string => "[<-"
|
106
|
+
# -- tailed string => "->]"
|
107
|
+
# --
|
108
|
+
# -- Why true? Because the little string "secret" is
|
109
|
+
# -- (wrapped) topped by "[<-" and tailed by "->]"
|
110
|
+
# --
|
111
|
+
# -- -----------------------------------------
|
112
|
+
# -- Assumptions | Constraints | Boundaries
|
113
|
+
# -- -----------------------------------------
|
114
|
+
# --
|
115
|
+
# -- - all matches are [case sensitive]
|
116
|
+
# -- - this string must contain little_str
|
117
|
+
# -- - one strike and its true
|
118
|
+
# -- (if little string appears more than once)
|
119
|
+
# -- so => "all secrets, most [<-secrets->] r juicy"
|
120
|
+
# -- => true as long as (at least) one is wrapped
|
121
|
+
# --
|
122
|
+
# --
|
123
|
+
def has_wrapped? little_str, prefix, postfix
|
124
|
+
|
125
|
+
return self.include?( prefix + little_str + postfix )
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
# --
|
131
|
+
# -- Sandwich the first occurrence of a substring in
|
132
|
+
# -- this string with the specified pre and postfix.
|
133
|
+
# --
|
134
|
+
# -- This string contains the little string and an
|
135
|
+
# -- IN-PLACE change is performed with the first
|
136
|
+
# -- occurrence of the little string being prefixed
|
137
|
+
# -- and postfixed with the 2 parameter strings.
|
138
|
+
# --
|
139
|
+
# -- ----------------------------------
|
140
|
+
# -- Example of sandwiching [wrapping]
|
141
|
+
# -- ----------------------------------
|
142
|
+
# --
|
143
|
+
# -- [String] => "Hey secrets are juicy."
|
144
|
+
# -- [To_Wrap] => "secrets"
|
145
|
+
# -- [Prefix] => "[<-"
|
146
|
+
# -- [Postfix] => "->]"
|
147
|
+
# --
|
148
|
+
# -- [String] => "Hey [<-secrets->] are juicy."
|
149
|
+
# --
|
150
|
+
# -- This string IS changed in place.
|
151
|
+
# --
|
152
|
+
def sandwich_substr to_wrap_str, prefix, postfix
|
153
|
+
|
154
|
+
occurs_index = self.downcase.index to_wrap_str.downcase
|
155
|
+
self.insert occurs_index, prefix
|
156
|
+
shifted_index = occurs_index + prefix.length + to_wrap_str.length
|
157
|
+
self.insert shifted_index, postfix
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
# --
|
163
|
+
# -- Return [TRUE] if this string includes [every word] harboured
|
164
|
+
# -- by the parameter array, else return [FALSE]. The "include"
|
165
|
+
# -- is a case-sensitive search.
|
166
|
+
# --
|
167
|
+
# -- -----------
|
168
|
+
# -- Parameter
|
169
|
+
# -- -----------
|
170
|
+
# --
|
171
|
+
# -- word_array : array of string words for the inclusivity test
|
172
|
+
# --
|
173
|
+
# -- --------------------------------
|
174
|
+
# -- Dependencies and Assumptions
|
175
|
+
# -- --------------------------------
|
176
|
+
# --
|
177
|
+
# -- the parameter string is not nil
|
178
|
+
# -- array can be [empty] but not nil
|
179
|
+
# -- array contents are neither nil nor empty
|
180
|
+
# --
|
181
|
+
def includes_all? word_array
|
182
|
+
|
183
|
+
Throw.if_nil self
|
184
|
+
Throw.if_nil word_array
|
185
|
+
|
186
|
+
word_array.each do |word|
|
187
|
+
|
188
|
+
Throw.if_nil word
|
189
|
+
return false unless self.include? word
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
return true
|
194
|
+
|
195
|
+
end
|
196
|
+
|
197
|
+
|
198
|
+
# --
|
199
|
+
# -- return true if the string includes [ANY] word within the
|
200
|
+
# -- parameter array, else return false. The "include" is done
|
201
|
+
# -- as a case-sensitive search.
|
202
|
+
# --
|
203
|
+
# -- -----------
|
204
|
+
# -- Parameter
|
205
|
+
# -- -----------
|
206
|
+
# --
|
207
|
+
# -- word_array : array of string words for the inclusivity test
|
208
|
+
# --
|
209
|
+
# -- --------------------------------
|
210
|
+
# -- Dependencies and Assumptions
|
211
|
+
# -- --------------------------------
|
212
|
+
# --
|
213
|
+
# -- array can be [empty] but not nil
|
214
|
+
# -- array contents are neither nil nor empty
|
215
|
+
# --
|
216
|
+
def includes_any? word_array
|
217
|
+
|
218
|
+
Throw.if_nil self
|
219
|
+
Throw.if_nil word_array
|
220
|
+
|
221
|
+
word_array.each do |word|
|
222
|
+
|
223
|
+
Throw.if_nil word
|
224
|
+
return true if self.include? word
|
225
|
+
|
226
|
+
end
|
227
|
+
|
228
|
+
return false
|
229
|
+
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
# --
|
234
|
+
# -- Encrypt this string with the parameter encryption/decryption key
|
235
|
+
# -- and return the encrypted text as a new string.
|
236
|
+
# --
|
237
|
+
# -- decrypt_key => the key that will decrypt the output string
|
238
|
+
# --
|
239
|
+
# --
|
240
|
+
def encrypt decrypt_key
|
241
|
+
|
242
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
243
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
244
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
245
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
246
|
+
|
247
|
+
###### ON Linux improve by changing to OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
|
248
|
+
###### ON Linux improve by changing to Digest::SHA2.hexdigest decrypt_key
|
249
|
+
###### ON Linux improve by changing to OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
|
250
|
+
###### ON Linux improve by changing to Digest::SHA2.hexdigest decrypt_key
|
251
|
+
###### ON Linux improve by changing to OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
|
252
|
+
###### ON Linux improve by changing to Digest::SHA2.hexdigest decrypt_key
|
253
|
+
###### ON Linux improve by changing to OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
|
254
|
+
###### ON Linux improve by changing to Digest::SHA2.hexdigest decrypt_key
|
255
|
+
|
256
|
+
cipher = OpenSSL::Cipher::Cipher.new('DES-EDE3-CBC').encrypt
|
257
|
+
cipher.key = Digest::SHA1.hexdigest decrypt_key
|
258
|
+
crypted = cipher.update(self) + cipher.final
|
259
|
+
encrypted_text = crypted.unpack('H*')[0].upcase
|
260
|
+
|
261
|
+
return encrypted_text
|
262
|
+
|
263
|
+
end
|
264
|
+
|
265
|
+
|
266
|
+
# --
|
267
|
+
# -- Decrypt this string with the parameter encryption/decryption key
|
268
|
+
# -- and return the decrypted text as a new string.
|
269
|
+
# --
|
270
|
+
# -- encrypt_key => the key the input string was encrypted with
|
271
|
+
# --
|
272
|
+
# --
|
273
|
+
def decrypt encrypt_key
|
274
|
+
|
275
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
276
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
277
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
278
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
279
|
+
|
280
|
+
###### ON Linux improve by changing to OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
|
281
|
+
###### ON Linux improve by changing to Digest::SHA2.hexdigest decrypt_key
|
282
|
+
###### ON Linux improve by changing to OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
|
283
|
+
###### ON Linux improve by changing to Digest::SHA2.hexdigest decrypt_key
|
284
|
+
###### ON Linux improve by changing to OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
|
285
|
+
###### ON Linux improve by changing to Digest::SHA2.hexdigest decrypt_key
|
286
|
+
|
287
|
+
cipher = OpenSSL::Cipher::Cipher.new('DES-EDE3-CBC').decrypt
|
288
|
+
cipher.key = Digest::SHA1.hexdigest encrypt_key
|
289
|
+
uncrypted = [self].pack("H*").unpack("C*").pack("c*")
|
290
|
+
decrypted_text = cipher.update(uncrypted) + cipher.final
|
291
|
+
|
292
|
+
return decrypted_text
|
293
|
+
|
294
|
+
end
|
295
|
+
|
296
|
+
|
297
|
+
# --
|
298
|
+
# -- Log the string which is expected to be delineated.
|
299
|
+
# -- If the string originated from a file it will be logged
|
300
|
+
# -- line by line. If no line delineation the string will be
|
301
|
+
# -- dumped just as a blob.
|
302
|
+
# --
|
303
|
+
def log_lines
|
304
|
+
|
305
|
+
self.each_line do |line|
|
306
|
+
clean_line = line.chomp.gsub("\\n","")
|
307
|
+
log.info(ere) { line } if clean_line.length > 0
|
308
|
+
end
|
309
|
+
|
310
|
+
end
|
311
|
+
|
312
|
+
end
|