rubyment 0.4.25421176 → 0.4.25421266
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/rubyment.rb +42 -27
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3cf5f393692d86f56ec7ae005f248e37f27984d
|
4
|
+
data.tar.gz: 81765d975abbb790820c0de5db2b5a1f61ff5c8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46f41aaeadd44170dbc8472520198f97043b719dc3a1b6ae3fe2678de5a22e565ad118584192a95c34903cdf521108b79889cc1177512e4c175ae6961ece36b4
|
7
|
+
data.tar.gz: da2b1a63e53cddb54b654d8c353b08a655ffa554dcf2d5863aef9efe78afc999143c2e184e242b9ae2d42d52455471dc43c05fdcdd189822237c44bf4decdced
|
data/lib/rubyment.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
# Collection of Ruby functions
|
4
|
-
#
|
5
|
-
# normally outputs to STDERR
|
4
|
+
# === Output
|
5
|
+
# normally outputs to +STDERR+, with
|
6
6
|
# no mercy
|
7
7
|
# STDOUT, just qualified output:
|
8
8
|
# only if the function is expected
|
@@ -431,23 +431,23 @@ class Rubyment
|
|
431
431
|
end
|
432
432
|
|
433
433
|
|
434
|
-
#
|
435
|
-
# big_file(bool) is a flag to set padding to 0.
|
434
|
+
# decipher the data encoded by enc
|
436
435
|
#
|
437
|
-
#
|
438
|
-
#
|
439
|
-
#
|
440
|
-
#
|
441
|
-
#
|
442
|
-
#
|
443
|
-
#
|
436
|
+
# @param [Array] args, an +Array+ whose elements are expected to be:
|
437
|
+
# +password+:: [String, nil] password to be used to encryption.
|
438
|
+
# +base64_iv+:: [String, nil] initialization vectors encoded with Base64
|
439
|
+
# +base64_encrypted+:: [String, nil] ciphered data (without metadata) encoded with Base64
|
440
|
+
# +ending+:: [nil] deprecated
|
441
|
+
# +base64_salt+:: [String, nil] #generate_pbkdf2_key salt encoded with Base64
|
442
|
+
# +base64_iter+:: [String, nil] #generate_pbkdf2_key iterations encoded with Base64
|
444
443
|
#
|
444
|
+
# @return [String] decoded data
|
445
445
|
def dec args=ARGV
|
446
446
|
require 'openssl'
|
447
447
|
require 'base64'
|
448
448
|
memory = @memory
|
449
449
|
static_end_key = memory[:static_end_key]
|
450
|
-
password,
|
450
|
+
password, base64_iv, base64_encrypted, ending, base64_salt, base64_iter = args
|
451
451
|
salt = Base64.decode64 base64_salt
|
452
452
|
iter = Base64.decode64 base64_iter
|
453
453
|
ending = ending.to_s.split("\0").first || static_end_key
|
@@ -460,8 +460,8 @@ class Rubyment
|
|
460
460
|
decipher.padding = 0
|
461
461
|
|
462
462
|
decipher.key = key || (Digest::SHA256.hexdigest password)
|
463
|
-
decipher.iv = Base64.decode64
|
464
|
-
plain = decipher.update(Base64.decode64
|
463
|
+
decipher.iv = Base64.decode64 base64_iv
|
464
|
+
plain = decipher.update(Base64.decode64 base64_encrypted) + decipher.final
|
465
465
|
# split is not the ideal, if ever ending is duplicated it won't
|
466
466
|
# work. also may be innefficient.
|
467
467
|
(plain.split ending).first
|
@@ -547,14 +547,23 @@ class Rubyment
|
|
547
547
|
shell_dec_output [pw_plain]
|
548
548
|
end
|
549
549
|
|
550
|
-
|
551
|
-
#
|
550
|
+
|
551
|
+
# encode data into aes-128-cbc cipher protected by a key generated
|
552
|
+
# by #generate_pbkdf2_key, using given +password+, +salt+, +iter+
|
552
553
|
#
|
553
|
-
#
|
554
|
-
#
|
555
|
-
#
|
556
|
-
#
|
557
|
-
#
|
554
|
+
# @param [Array] args, an +Array+ whose elements are expected to be:
|
555
|
+
# +password+:: [String, nil] password to be used to encryption.
|
556
|
+
# +data+:: [String, nil] data to be encoded data
|
557
|
+
# +ending+:: [nil] deprecated
|
558
|
+
# +salt+:: [String, nil] #generate_pbkdf2_key salt argument
|
559
|
+
# +iter+:: [String, nil] #generate_pbkdf2_key iterations argument
|
560
|
+
#
|
561
|
+
# @return @param [Array] an +Array+ whose elements are expected to be:
|
562
|
+
# +base64_encrypted+:: [String, nil] ciphered data (without metadata) encoded with Base64
|
563
|
+
# +base64_iv+:: [String] initialization vectors encoded with Base64
|
564
|
+
# +base64_salt+:: [String] #generate_pbkdf2_key salt encoded with Base64
|
565
|
+
# +base64_iter+:: [String] #generate_pbkdf2_key iterations encoded with Base64
|
566
|
+
# +base64_key+:: [String] #generate_pbkdf2_key return value
|
558
567
|
#
|
559
568
|
def enc args=ARGV
|
560
569
|
require 'openssl'
|
@@ -762,10 +771,10 @@ class Rubyment
|
|
762
771
|
# an alternative interface to dec -- reads password if
|
763
772
|
# nil or empty.
|
764
773
|
#
|
765
|
-
# @param [Array] args
|
766
|
-
#
|
767
|
-
# echo) from @memory[:stdin], which defaults to STDIN
|
768
|
-
#
|
774
|
+
# @param [Array] args, an +Array+ whose elements are expected to be:
|
775
|
+
# +iv+:: [String, nil]
|
776
|
+
# If empty or nil, read (without echo) from @memory[:stdin], which defaults to STDIN
|
777
|
+
# +password+:: [String, nil] password to be used to encryption.
|
769
778
|
# If empty or nil, read (without echo) from @memory[:stdin], which defaults to STDIN
|
770
779
|
#
|
771
780
|
# @return [TrueClass, FalseClass] depending on whether test succeeds.
|
@@ -809,8 +818,14 @@ class Rubyment
|
|
809
818
|
|
810
819
|
|
811
820
|
# test for enc and dec.
|
812
|
-
#
|
813
|
-
#
|
821
|
+
#
|
822
|
+
# @param [Array] args, an +Array+ whose elements are expected to be:
|
823
|
+
# +data+:: [String, nil] data to be encrypted.
|
824
|
+
# If empty or nil, read (without echo) from @memory[:stdin], which defaults to STDIN
|
825
|
+
# +password+:: [String, nil] password to be used to encryption.
|
826
|
+
# If empty or nil, read (without echo) from @memory[:stdin], which defaults to STDIN
|
827
|
+
#
|
828
|
+
# @return [TrueClass, FalseClass] depending on whether test succeeds.
|
814
829
|
def test__enc_dec args=ARGV
|
815
830
|
stderr = @memory[:stderr]
|
816
831
|
data, password = args
|