Class: Fastlane::Helper::EncryptionHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::EncryptionHelper
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/helper/encryption_helper.rb
Defined Under Namespace
Modules: OperationType
Class Method Summary collapse
- .cipher(op_type) ⇒ Object
- .decrypt(encrypted, key) ⇒ Object
- .encrypt(plain_text, key) ⇒ Object
- .generate_key ⇒ Object
Class Method Details
.cipher(op_type) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/encryption_helper.rb', line 13 def self.cipher(op_type) cipher = OpenSSL::Cipher.new('aes-256-cbc') cipher.encrypt if op_type == OperationType::ENCRYPT cipher.decrypt if op_type == OperationType::DECRYPT cipher end |
.decrypt(encrypted, key) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/encryption_helper.rb', line 32 def self.decrypt(encrypted, key) cipher = cipher(OperationType::DECRYPT) cipher.key = key decrypted = cipher.update(encrypted) + cipher.final # Ensure consistent encoding decrypted.force_encoding(Encoding::UTF_8) decrypted end |
.encrypt(plain_text, key) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/encryption_helper.rb', line 22 def self.encrypt(plain_text, key) # Ensure consistent encoding sanitized_plain_text = plain_text.dup.force_encoding(Encoding::UTF_8) cipher = cipher(OperationType::ENCRYPT) cipher.key = key cipher.update(sanitized_plain_text) + cipher.final end |
.generate_key ⇒ Object
44 45 46 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/encryption_helper.rb', line 44 def self.generate_key cipher(OperationType::ENCRYPT).random_key end |