safedb 0.01.0001
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 +7 -0
- data/.gitignore +8 -0
- data/.yardopts +3 -0
- data/Gemfile +10 -0
- data/LICENSE +21 -0
- data/README.md +793 -0
- data/Rakefile +16 -0
- data/bin/safe +5 -0
- data/lib/configs/README.md +58 -0
- data/lib/extension/array.rb +162 -0
- data/lib/extension/dir.rb +35 -0
- data/lib/extension/file.rb +123 -0
- data/lib/extension/hash.rb +33 -0
- data/lib/extension/string.rb +572 -0
- data/lib/factbase/facts.safedb.net.ini +38 -0
- data/lib/interprete.rb +462 -0
- data/lib/keytools/PRODUCE_RAND_SEQ_USING_DEV_URANDOM.txt +0 -0
- data/lib/keytools/kdf.api.rb +243 -0
- data/lib/keytools/kdf.bcrypt.rb +265 -0
- data/lib/keytools/kdf.pbkdf2.rb +262 -0
- data/lib/keytools/kdf.scrypt.rb +190 -0
- data/lib/keytools/key.64.rb +326 -0
- data/lib/keytools/key.algo.rb +109 -0
- data/lib/keytools/key.api.rb +1391 -0
- data/lib/keytools/key.db.rb +330 -0
- data/lib/keytools/key.docs.rb +195 -0
- data/lib/keytools/key.error.rb +110 -0
- data/lib/keytools/key.id.rb +271 -0
- data/lib/keytools/key.ident.rb +243 -0
- data/lib/keytools/key.iv.rb +107 -0
- data/lib/keytools/key.local.rb +259 -0
- data/lib/keytools/key.now.rb +402 -0
- data/lib/keytools/key.pair.rb +259 -0
- data/lib/keytools/key.pass.rb +120 -0
- data/lib/keytools/key.rb +585 -0
- data/lib/logging/gem.logging.rb +132 -0
- data/lib/modules/README.md +43 -0
- data/lib/modules/cryptology/aes-256.rb +154 -0
- data/lib/modules/cryptology/amalgam.rb +70 -0
- data/lib/modules/cryptology/blowfish.rb +130 -0
- data/lib/modules/cryptology/cipher.rb +207 -0
- data/lib/modules/cryptology/collect.rb +138 -0
- data/lib/modules/cryptology/crypt.io.rb +225 -0
- data/lib/modules/cryptology/engineer.rb +99 -0
- data/lib/modules/mappers/dictionary.rb +288 -0
- data/lib/modules/storage/coldstore.rb +186 -0
- data/lib/modules/storage/git.store.rb +399 -0
- data/lib/session/fact.finder.rb +334 -0
- data/lib/session/require.gem.rb +112 -0
- data/lib/session/time.stamp.rb +340 -0
- data/lib/session/user.home.rb +49 -0
- data/lib/usecase/cmd.rb +487 -0
- data/lib/usecase/config/README.md +57 -0
- data/lib/usecase/docker/README.md +146 -0
- data/lib/usecase/docker/docker.rb +49 -0
- data/lib/usecase/edit/README.md +43 -0
- data/lib/usecase/edit/delete.rb +46 -0
- data/lib/usecase/export.rb +40 -0
- data/lib/usecase/files/README.md +37 -0
- data/lib/usecase/files/eject.rb +56 -0
- data/lib/usecase/files/file_me.rb +78 -0
- data/lib/usecase/files/read.rb +169 -0
- data/lib/usecase/files/write.rb +89 -0
- data/lib/usecase/goto.rb +57 -0
- data/lib/usecase/id.rb +36 -0
- data/lib/usecase/import.rb +157 -0
- data/lib/usecase/init.rb +63 -0
- data/lib/usecase/jenkins/README.md +146 -0
- data/lib/usecase/jenkins/jenkins.rb +208 -0
- data/lib/usecase/login.rb +71 -0
- data/lib/usecase/logout.rb +28 -0
- data/lib/usecase/open.rb +71 -0
- data/lib/usecase/print.rb +40 -0
- data/lib/usecase/put.rb +81 -0
- data/lib/usecase/set.rb +44 -0
- data/lib/usecase/show.rb +138 -0
- data/lib/usecase/terraform/README.md +91 -0
- data/lib/usecase/terraform/terraform.rb +121 -0
- data/lib/usecase/token.rb +35 -0
- data/lib/usecase/update/README.md +55 -0
- data/lib/usecase/update/rename.rb +180 -0
- data/lib/usecase/use.rb +41 -0
- data/lib/usecase/verse.rb +20 -0
- data/lib/usecase/view.rb +71 -0
- data/lib/usecase/vpn/README.md +150 -0
- data/lib/usecase/vpn/vpn.ini +31 -0
- data/lib/usecase/vpn/vpn.rb +54 -0
- data/lib/version.rb +3 -0
- data/safedb.gemspec +34 -0
- metadata +193 -0
@@ -0,0 +1,572 @@
|
|
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
|
+
class String
|
13
|
+
|
14
|
+
## ################################################
|
15
|
+
## ################################################
|
16
|
+
## ################################################
|
17
|
+
## ################################################
|
18
|
+
## https://www.di-mgt.com.au/cryptokeys.html
|
19
|
+
## ################################################
|
20
|
+
## ################################################
|
21
|
+
## ################################################
|
22
|
+
## ################################################
|
23
|
+
## ################################################
|
24
|
+
|
25
|
+
# Encrypt this string with the parameter symmetric encryption/decryption key
|
26
|
+
# and then return the Base64 (block mode) encoded result.
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# cipher_text = "Hello crypt world".encrypt_block_encode "ABC123XYZ"
|
30
|
+
# original_txt = cipher_text.block_decode_decrypt "ABC123XYZ"
|
31
|
+
# puts original_txt # "Hello crypt world"
|
32
|
+
#
|
33
|
+
# @param crypt_key [String]
|
34
|
+
# a strong long encryption key that is used to encrypt this string before
|
35
|
+
# applying the Base64 block encoding.
|
36
|
+
def encrypt_block_encode crypt_key
|
37
|
+
encrypted_text = SafeDb::ToolBelt::Blowfish.encryptor( self, crypt_key )
|
38
|
+
return Base64.encode64( encrypted_text )
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
# First apply a base64 (block mode) decode to this string and then use the
|
44
|
+
# parameter symmetric decryption key to decrypt the result. The output is then
|
45
|
+
# returned within a new string.
|
46
|
+
#
|
47
|
+
# @example
|
48
|
+
# cipher_text = "Hello crypt world".decrypt_block_encode "ABC123XYZ"
|
49
|
+
# original_txt = cipher_text.block_decode_decrypt "ABC123XYZ"
|
50
|
+
# puts original_txt # "Hello crypt world"
|
51
|
+
#
|
52
|
+
# @param crypt_key [String]
|
53
|
+
# a strong long decryption key that is used to decrypt this string after
|
54
|
+
# the Base64 block decoding has been applied.
|
55
|
+
def block_decode_decrypt crypt_key
|
56
|
+
the_ciphertxt = Base64.decode64( self )
|
57
|
+
return SafeDb::ToolBelt::Blowfish.decryptor( the_ciphertxt, crypt_key )
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
# Encrypt this string with the parameter symmetric encryption/decryption key
|
63
|
+
# and then return the Base64 (url safe mode) encoded result.
|
64
|
+
#
|
65
|
+
# The output will be a single line and differs from the block mode with
|
66
|
+
#
|
67
|
+
# - underscores printed instead of forward slash characters
|
68
|
+
# - hyphens printed instead of plus characters
|
69
|
+
# - no (blocked) carriage return or new line characters
|
70
|
+
#
|
71
|
+
# Note however that sometimes one or more equals characters will be printed at
|
72
|
+
# the end of the string by way of padding. In places like environment variables
|
73
|
+
# that are sensitive to the equals character this can be replaced by an <b>@</b>
|
74
|
+
# symbol.
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# cipher_text = "Hello @:==:@ world".encrypt_url_encode "ABC123XYZ"
|
78
|
+
# original_txt = cipher_text.url_decode_decrypt "ABC123XYZ"
|
79
|
+
# puts original_txt # "Hello @:==:@ world"
|
80
|
+
#
|
81
|
+
# @param crypt_key [String]
|
82
|
+
# a strong long encryption key that is used to encrypt this string before
|
83
|
+
# applying the Base64 ul safe encoding.
|
84
|
+
def encrypt_url_encode crypt_key
|
85
|
+
|
86
|
+
## ################################################
|
87
|
+
## ################################################
|
88
|
+
## ################################################
|
89
|
+
## ################################################
|
90
|
+
## https://www.di-mgt.com.au/cryptokeys.html
|
91
|
+
## ################################################
|
92
|
+
## ################################################
|
93
|
+
## ################################################
|
94
|
+
## ################################################
|
95
|
+
## ################################################
|
96
|
+
|
97
|
+
log.info(x){ "Encrypt Length => [ #{self.length} ]" }
|
98
|
+
log.info(x){ "The Key Length => [ #{crypt_key.length} ]" }
|
99
|
+
log.info(x){ "Encrypt String => [ #{self} ]" }
|
100
|
+
log.info(x){ "Encryption Key => [ #{crypt_key} ]" }
|
101
|
+
|
102
|
+
encrypted_text = SafeDb::ToolBelt::Blowfish.encryptor( self, crypt_key )
|
103
|
+
|
104
|
+
log.info(x){ "Encrypt Result => [ #{encrypted_text} ]" }
|
105
|
+
log.info(x){ "Encrypted Text => [ #{Base64.urlsafe_encode64(encrypted_text)} ]" }
|
106
|
+
|
107
|
+
return Base64.urlsafe_encode64(encrypted_text)
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
# First apply a base64 (url safe mode) decode to this string and then use the
|
114
|
+
# parameter symmetric decryption key to decrypt the result. The output is then
|
115
|
+
# returned within a new string.
|
116
|
+
#
|
117
|
+
# The input must will be a single line and differs from the block mode with
|
118
|
+
#
|
119
|
+
# - underscores printed instead of forward slash characters
|
120
|
+
# - hyphens printed instead of plus characters
|
121
|
+
# - no (blocked) carriage return or new line characters
|
122
|
+
#
|
123
|
+
# @example
|
124
|
+
# cipher_text = "Hello @:==:@ world".encrypt_url_encode "ABC123XYZ"
|
125
|
+
# original_txt = cipher_text.url_decode_decrypt "ABC123XYZ"
|
126
|
+
# puts original_txt # "Hello @:==:@ world"
|
127
|
+
#
|
128
|
+
# @param crypt_key [String]
|
129
|
+
# a strong long decryption key that is used to decrypt this string after
|
130
|
+
# the Base64 url safe decoding has been applied.
|
131
|
+
def url_decode_decrypt crypt_key
|
132
|
+
the_ciphertxt = Base64.urlsafe_decode64( self )
|
133
|
+
return SafeDb::ToolBelt::Blowfish.decryptor( the_ciphertxt, crypt_key )
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
# Overtly long file paths (eg in logs) can hamper readability so this
|
140
|
+
# <b>human readable filepath converter</b> counters the problem by
|
141
|
+
# returning (only) the 2 immediate ancestors of the filepath.
|
142
|
+
#
|
143
|
+
# So this method returns the name of the grandparent folder then parent folder
|
144
|
+
# and then the most significant file (or folder) name.
|
145
|
+
#
|
146
|
+
# When this is not possible due to the filepath being colisively near the
|
147
|
+
# filesystem's root, it returns the parameter name.
|
148
|
+
#
|
149
|
+
# @example
|
150
|
+
# A really long input like
|
151
|
+
# => /home/joe/project/degrees/math/2020
|
152
|
+
# is reduced to
|
153
|
+
# => degrees/math/2020
|
154
|
+
#
|
155
|
+
# @return [String] the segmented 3 most significant path name elements.
|
156
|
+
def hr_path
|
157
|
+
|
158
|
+
object_name = File.basename self
|
159
|
+
parent_folder = File.dirname self
|
160
|
+
parent_name = File.basename parent_folder
|
161
|
+
granny_folder = File.dirname parent_folder
|
162
|
+
granny_name = File.basename granny_folder
|
163
|
+
|
164
|
+
return [granny_name,parent_name,object_name].join("/")
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
# Return a new string matching this one with every non alpha-numeric
|
170
|
+
# character removed. This string is left unchanged.
|
171
|
+
#
|
172
|
+
# Spaces, hyphens, underscores, periods are all removed. The only
|
173
|
+
# characters left standing belong to a set of 62 and are
|
174
|
+
#
|
175
|
+
# - a to z
|
176
|
+
# - A to Z
|
177
|
+
# - 0 to 9
|
178
|
+
#
|
179
|
+
# @return [String]
|
180
|
+
# Remove any character that is not alphanumeric, a to z, A to Z
|
181
|
+
# and 0 to 9 and return a new string leaving this one unchanged.
|
182
|
+
def to_alphanumeric
|
183
|
+
return self.delete("^A-Za-z0-9")
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
# Find the length of this string and return a string that is the
|
188
|
+
# concatenated union of this string and its integer length.
|
189
|
+
# If this string is empty a string of length one ie "0" will be
|
190
|
+
# returned.
|
191
|
+
#
|
192
|
+
# @return [String]
|
193
|
+
# Return this string with a cheeky integer tagged onto the end
|
194
|
+
# that represents the (pre-concat) length of the string.
|
195
|
+
def concat_length
|
196
|
+
return self + "#{self.length}"
|
197
|
+
end
|
198
|
+
|
199
|
+
|
200
|
+
# Get the text [in between] this and that delimiter [exclusively].
|
201
|
+
# Exclusively means the returned text [does not] include either of
|
202
|
+
# the matched delimiters (although an unmatched instance of [this]
|
203
|
+
# delimiter may appear in the in-between text).
|
204
|
+
#
|
205
|
+
# ### Multiple Delimiters
|
206
|
+
#
|
207
|
+
# When multiple delimiters exist, the text returned is in between the
|
208
|
+
#
|
209
|
+
# - first occurrence of [this] delimiter AND the
|
210
|
+
# - 1st occurrence of [that] delimiter [AFTER] the 1st delimiter
|
211
|
+
#
|
212
|
+
# Instances of [that] delimiter occurring before [this] are ignored.
|
213
|
+
# The text could contain [this] delimiter instances but is guaranteed
|
214
|
+
# not to contain a [that] delimiter.
|
215
|
+
#
|
216
|
+
# @throw an exception (error) will be thrown if
|
217
|
+
#
|
218
|
+
# - any nil (or empties) exist in the input parameters
|
219
|
+
# - **this** delimiter does not appear in the in_string
|
220
|
+
# - **that** delimiter does not appear after [this] one
|
221
|
+
#
|
222
|
+
# @param this_delimiter [String] begin delimiter (not included in returned string)
|
223
|
+
# @param that_delimiter [String] end delimiter (not included in returned string)
|
224
|
+
#
|
225
|
+
# @return [String] the text in between (excluding) the two parameter delimiters
|
226
|
+
def in_between this_delimiter, that_delimiter
|
227
|
+
|
228
|
+
raise ArgumentError, "This string is NIL or empty." if self.nil? || self.empty?
|
229
|
+
raise ArgumentError, "Begin delimiter is NIL or empty." if this_delimiter.nil? || this_delimiter.empty?
|
230
|
+
raise ArgumentError, "End delimiter is NIL or empty." if that_delimiter.nil? || that_delimiter.empty?
|
231
|
+
|
232
|
+
scanner_1 = StringScanner.new self
|
233
|
+
scanner_1.scan_until /#{this_delimiter}/
|
234
|
+
scanner_2 = StringScanner.new scanner_1.post_match
|
235
|
+
scanner_2.scan_until /#{that_delimiter}/
|
236
|
+
|
237
|
+
in_between_text = scanner_2.pre_match.strip
|
238
|
+
return in_between_text
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
|
243
|
+
# To hex converts this string to hexadecimal form and returns
|
244
|
+
# the result leaving this string unchanged.
|
245
|
+
# @return [String] hexadecimal representation of this string
|
246
|
+
def to_hex
|
247
|
+
|
248
|
+
return self.unpack("H*").first
|
249
|
+
|
250
|
+
end
|
251
|
+
|
252
|
+
|
253
|
+
# From hex converts this (assumed) hexadecimal string back into
|
254
|
+
# its normal string form and returns the result leaving this string
|
255
|
+
# unchanged.
|
256
|
+
# @return [String] string that matches the hexadecimal representation
|
257
|
+
def from_hex
|
258
|
+
|
259
|
+
return [self].pack("H*")
|
260
|
+
|
261
|
+
end
|
262
|
+
|
263
|
+
|
264
|
+
# Flatten (lower) a camel cased string and add periods to
|
265
|
+
# denote separation where the capital letters used to be.
|
266
|
+
#
|
267
|
+
# Example behaviour is illustrated
|
268
|
+
#
|
269
|
+
# - in => ObjectOriented
|
270
|
+
# - out => object.oriented
|
271
|
+
#
|
272
|
+
# Even when a capital letter does not lead lowercase characters
|
273
|
+
# the behaviour should resemble this.
|
274
|
+
#
|
275
|
+
# - in => SuperX
|
276
|
+
# - out => super.x
|
277
|
+
#
|
278
|
+
#
|
279
|
+
# And if every letter is uppercase, each one represents its
|
280
|
+
# own section like this.
|
281
|
+
#
|
282
|
+
# - in => BEAST
|
283
|
+
# - out => b.e.a.s.t
|
284
|
+
#
|
285
|
+
# == Flatten Class Names
|
286
|
+
#
|
287
|
+
# If the string comes in as a class name we can expect it to
|
288
|
+
# contain colons like the below examples.
|
289
|
+
# This::That
|
290
|
+
# ::That
|
291
|
+
# This::That::TheOther
|
292
|
+
#
|
293
|
+
# So we find the last index of a colon and then continue as per
|
294
|
+
# the above with flattening the string.
|
295
|
+
#
|
296
|
+
# @return [String] a flatten (period separated) version of this camel cased string
|
297
|
+
def do_flatten
|
298
|
+
|
299
|
+
to_flatten_str = self
|
300
|
+
|
301
|
+
last_colon_index = to_flatten_str.rindex ":"
|
302
|
+
ends_with_colon = to_flatten_str[-1].eql? ":"
|
303
|
+
unless ( last_colon_index.nil? || ends_with_colon )
|
304
|
+
to_flatten_str = to_flatten_str[ (last_colon_index+1) .. -1 ]
|
305
|
+
end
|
306
|
+
|
307
|
+
snapped_str = ""
|
308
|
+
to_flatten_str.each_char do |this_char|
|
309
|
+
is_lower = "#{this_char}".is_all_lowercase?
|
310
|
+
snapped_str += "." unless is_lower || snapped_str.empty?
|
311
|
+
snapped_str += this_char.downcase
|
312
|
+
end
|
313
|
+
|
314
|
+
return snapped_str
|
315
|
+
|
316
|
+
end
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
# Return true if every character in this string is lowercase.
|
321
|
+
# Note that if this string is empty this method returns true.
|
322
|
+
#
|
323
|
+
# @return true if every alpha character in this string is lowercase
|
324
|
+
def is_all_lowercase?
|
325
|
+
return self.downcase.eql? self
|
326
|
+
end
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
# Flatten (lower) a camel cased string and add periods to
|
331
|
+
# denote separation where the capital letters used to be.
|
332
|
+
# The inverse operation to [ do_flatten ] which resurrects
|
333
|
+
# this (expected) period separated string changing it back
|
334
|
+
# to a camel (mountain) cased string.
|
335
|
+
#
|
336
|
+
# Example behaviour is illustrated
|
337
|
+
#
|
338
|
+
# - in => object.oriented
|
339
|
+
# - out => ObjectOriented
|
340
|
+
#
|
341
|
+
# Even when a single character exists to the right of the period
|
342
|
+
# the behaviour should resemble this.
|
343
|
+
#
|
344
|
+
# - in => super.x
|
345
|
+
# - out => SuperX
|
346
|
+
#
|
347
|
+
#
|
348
|
+
# And if every letter is period separated
|
349
|
+
#
|
350
|
+
# - in => b.e.a.s.t
|
351
|
+
# - out => BEAST
|
352
|
+
#
|
353
|
+
# @return [String] camel cased version of this flattened (period separated) string
|
354
|
+
def un_flatten
|
355
|
+
|
356
|
+
segment_array = self.strip.split "."
|
357
|
+
resurrected_arr = Array.new
|
358
|
+
|
359
|
+
segment_array.each do |seg_word|
|
360
|
+
resurrected_arr.push seg_word.capitalize
|
361
|
+
end
|
362
|
+
|
363
|
+
undone_str = resurrected_arr.join
|
364
|
+
log.info(x){ "unflattening => [#{self}] and resurrecting to => [#{undone_str}]" }
|
365
|
+
|
366
|
+
return undone_str
|
367
|
+
|
368
|
+
end
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
# --
|
373
|
+
# Return true if the [little string] within this
|
374
|
+
# string object is both
|
375
|
+
# --
|
376
|
+
# a] topped by the parameter prefix AND
|
377
|
+
# b] tailed by the parameter postfix
|
378
|
+
# --
|
379
|
+
# -----------------------------------------
|
380
|
+
# In the below example [true] is returned
|
381
|
+
# -----------------------------------------
|
382
|
+
# --
|
383
|
+
# This [String] => "Hey [<-secrets->] are juicy."
|
384
|
+
# little string => "secrets"
|
385
|
+
# topped string => "[<-"
|
386
|
+
# tailed string => "->]"
|
387
|
+
# --
|
388
|
+
# Why true? Because the little string "secret" is
|
389
|
+
# (wrapped) topped by "[<-" and tailed by "->]"
|
390
|
+
# --
|
391
|
+
# -----------------------------------------
|
392
|
+
# Assumptions | Constraints | Boundaries
|
393
|
+
# -----------------------------------------
|
394
|
+
# --
|
395
|
+
# - all matches are [case sensitive]
|
396
|
+
# - this string must contain little_str
|
397
|
+
# - one strike and its true
|
398
|
+
# (if little string appears more than once)
|
399
|
+
# so => "all secrets, most [<-secrets->] r juicy"
|
400
|
+
# => true as long as (at least) one is wrapped
|
401
|
+
# --
|
402
|
+
# --
|
403
|
+
def has_wrapped? little_str, prefix, postfix
|
404
|
+
|
405
|
+
return self.include?( prefix + little_str + postfix )
|
406
|
+
|
407
|
+
end
|
408
|
+
|
409
|
+
|
410
|
+
# Sandwich the first occurrence of a substring in
|
411
|
+
# this string with the specified pre and postfix.
|
412
|
+
#
|
413
|
+
# This string contains the little string and an
|
414
|
+
# IN-PLACE change is performed with the first
|
415
|
+
# occurrence of the little string being prefixed
|
416
|
+
# and postfixed with the 2 parameter strings.
|
417
|
+
#
|
418
|
+
# Example of sandwiching [wrapping]
|
419
|
+
#
|
420
|
+
# - [String] => "Hey secrets are juicy."
|
421
|
+
# - [To_Wrap] => "secrets"
|
422
|
+
# - [Prefix] => "[<-"
|
423
|
+
# - [Postfix] => "->]"
|
424
|
+
#
|
425
|
+
# [String] => "Hey [<-secrets->] are juicy."
|
426
|
+
#
|
427
|
+
# This string IS changed in place.
|
428
|
+
def sandwich_substr to_wrap_str, prefix, postfix
|
429
|
+
|
430
|
+
occurs_index = self.downcase.index to_wrap_str.downcase
|
431
|
+
self.insert occurs_index, prefix
|
432
|
+
shifted_index = occurs_index + prefix.length + to_wrap_str.length
|
433
|
+
self.insert shifted_index, postfix
|
434
|
+
|
435
|
+
end
|
436
|
+
|
437
|
+
|
438
|
+
# The parameter is a list of character sequences and TRUE is returned
|
439
|
+
# if EVERY ONE of the character sequences is always found nestled somewhere
|
440
|
+
# within this string. The matching is case-sensitive.
|
441
|
+
#
|
442
|
+
# The parameter array can be [empty] but not nil. And the harboured
|
443
|
+
# character sequences can neither be nil nor empty.
|
444
|
+
#
|
445
|
+
# @param word_array [Array] array of string words for the inclusivity test
|
446
|
+
#
|
447
|
+
# @return [Boolean] true if EVERY ONE of the char sequences appear somewhere in this string
|
448
|
+
def includes_all? word_array
|
449
|
+
|
450
|
+
raise ArgumentError, "This string is NIL" if self.nil?
|
451
|
+
raise ArgumentError, "The parameter word array is NIL" if word_array.nil?
|
452
|
+
|
453
|
+
word_array.each do |word|
|
454
|
+
|
455
|
+
raise ArgumentError, "The word array #{word_array} contains a nil value." if word.nil?
|
456
|
+
return false unless self.include? word
|
457
|
+
|
458
|
+
end
|
459
|
+
|
460
|
+
return true
|
461
|
+
|
462
|
+
end
|
463
|
+
|
464
|
+
|
465
|
+
# The parameter is a list of character sequences and TRUE is returned
|
466
|
+
# if any one of the character sequences can be found nestled somewhere
|
467
|
+
# within this string. The matching is case-sensitive.
|
468
|
+
#
|
469
|
+
# The parameter array can be [empty] but not nil. And the harboured
|
470
|
+
# character sequences can neither be nil nor empty.
|
471
|
+
#
|
472
|
+
# @param word_array [Array] array of string words for the inclusivity test
|
473
|
+
#
|
474
|
+
# @return [Boolean] true if string includes ANY one of the character sequences in array
|
475
|
+
def includes_any? word_array
|
476
|
+
|
477
|
+
raise ArgumentError, "This string is NIL" if self.nil?
|
478
|
+
raise ArgumentError, "The parameter word array is NIL" if word_array.nil?
|
479
|
+
|
480
|
+
word_array.each do |word|
|
481
|
+
|
482
|
+
raise ArgumentError, "The word array #{word_array} contains a nil value." if word.nil?
|
483
|
+
return true if self.include? word
|
484
|
+
|
485
|
+
end
|
486
|
+
|
487
|
+
return false
|
488
|
+
|
489
|
+
end
|
490
|
+
|
491
|
+
|
492
|
+
# --
|
493
|
+
# Encrypt this string with the parameter encryption/decryption key
|
494
|
+
# and return the encrypted text as a new string.
|
495
|
+
# --
|
496
|
+
# decrypt_key => the key that will decrypt the output string
|
497
|
+
# --
|
498
|
+
# --
|
499
|
+
def encrypt decrypt_key
|
500
|
+
|
501
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
502
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
503
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
504
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
505
|
+
|
506
|
+
###### ON Linux improve by changing to OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
|
507
|
+
###### ON Linux improve by changing to Digest::SHA2.hexdigest decrypt_key
|
508
|
+
###### ON Linux improve by changing to OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
|
509
|
+
###### ON Linux improve by changing to Digest::SHA2.hexdigest decrypt_key
|
510
|
+
###### ON Linux improve by changing to OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
|
511
|
+
###### ON Linux improve by changing to Digest::SHA2.hexdigest decrypt_key
|
512
|
+
###### ON Linux improve by changing to OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
|
513
|
+
###### ON Linux improve by changing to Digest::SHA2.hexdigest decrypt_key
|
514
|
+
|
515
|
+
cipher = OpenSSL::Cipher::Cipher.new('DES-EDE3-CBC').encrypt
|
516
|
+
cipher.key = Digest::SHA1.hexdigest decrypt_key
|
517
|
+
crypted = cipher.update(self) + cipher.final
|
518
|
+
encrypted_text = crypted.unpack('H*')[0].upcase
|
519
|
+
|
520
|
+
return encrypted_text
|
521
|
+
|
522
|
+
end
|
523
|
+
|
524
|
+
|
525
|
+
# --
|
526
|
+
# Decrypt this string with the parameter encryption/decryption key
|
527
|
+
# and return the decrypted text as a new string.
|
528
|
+
# --
|
529
|
+
# encrypt_key => the key the input string was encrypted with
|
530
|
+
# --
|
531
|
+
# --
|
532
|
+
def decrypt encrypt_key
|
533
|
+
|
534
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
535
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
536
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
537
|
+
## ----> Write a RE-CRYPT method that goes through a folder - decrypting and recrypting
|
538
|
+
|
539
|
+
###### ON Linux improve by changing to OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
|
540
|
+
###### ON Linux improve by changing to Digest::SHA2.hexdigest decrypt_key
|
541
|
+
###### ON Linux improve by changing to OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
|
542
|
+
###### ON Linux improve by changing to Digest::SHA2.hexdigest decrypt_key
|
543
|
+
###### ON Linux improve by changing to OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
|
544
|
+
###### ON Linux improve by changing to Digest::SHA2.hexdigest decrypt_key
|
545
|
+
|
546
|
+
cipher = OpenSSL::Cipher::Cipher.new('DES-EDE3-CBC').decrypt
|
547
|
+
cipher.key = Digest::SHA1.hexdigest encrypt_key
|
548
|
+
uncrypted = [self].pack("H*").unpack("C*").pack("c*")
|
549
|
+
decrypted_text = cipher.update(uncrypted) + cipher.final
|
550
|
+
|
551
|
+
return decrypted_text
|
552
|
+
|
553
|
+
end
|
554
|
+
|
555
|
+
|
556
|
+
# Log the string which is expected to be delineated.
|
557
|
+
# If the string originated from a file it will be logged
|
558
|
+
# line by line. If no line delineation the string will be
|
559
|
+
# dumped just as a blob.
|
560
|
+
#
|
561
|
+
# The INFO log level is used to log the lines - if this is not
|
562
|
+
# appropriate create a (level) parameterized log lines method.
|
563
|
+
def log_lines
|
564
|
+
|
565
|
+
self.each_line do |line|
|
566
|
+
clean_line = line.chomp.gsub("\\n","")
|
567
|
+
log.info(x) { line } if clean_line.length > 0
|
568
|
+
end
|
569
|
+
|
570
|
+
end
|
571
|
+
|
572
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
[global]
|
3
|
+
|
4
|
+
name = safe
|
5
|
+
min.passwd.len = rb>> 6
|
6
|
+
root.domain = devopswiki.co.uk
|
7
|
+
env.var.name = SECRET_MATERIAL
|
8
|
+
ratio = rb>> 3
|
9
|
+
bit.key.size = rb>> 8192
|
10
|
+
key.cipher = rb>> OpenSSL::Cipher::AES256.new(:CBC)
|
11
|
+
|
12
|
+
domain.now.id = current.domain
|
13
|
+
front.path.id = frontend.path
|
14
|
+
machine.key.id = machine.p4ssk3y
|
15
|
+
time.stamp.id = domain.stamp
|
16
|
+
user.secret.id = user.secret
|
17
|
+
|
18
|
+
stamp.14 = rb>> OpenSession::Stamp.yyjjj_hhmm_sst
|
19
|
+
stamp.23 = rb>> OpenSession::Stamp.yyjjj_hhmm_ss_nanosec
|
20
|
+
|
21
|
+
separator.a = %$os$%
|
22
|
+
|
23
|
+
repo.name = material_data
|
24
|
+
config.file = ops.workstation.directive.ini
|
25
|
+
session.file = ops.session.configuration.ini
|
26
|
+
|
27
|
+
prompt.1 = Enter a Robust Password
|
28
|
+
prompt.2 = Re-enter that Password
|
29
|
+
|
30
|
+
|
31
|
+
[open]
|
32
|
+
|
33
|
+
open.name = session
|
34
|
+
open.idlen = rb>> 10
|
35
|
+
open.keylen = rb>> 56
|
36
|
+
open.idname = session.id
|
37
|
+
open.keyname = session.key
|
38
|
+
open.pathname = session.path
|