Class: ConfidentialInfoManager::JSON

Inherits:
Core
  • Object
show all
Defined in:
lib/confidential_info_manager/json.rb

Constant Summary

Constants inherited from Core

Core::ITERATOR_COUNT, Core::RANDOM_BYTES

Instance Method Summary collapse

Methods inherited from Core

#decrypt, #decrypt_only_value, #encrypt, #encrypt_only_value, generate_salt, #initialize

Constructor Details

This class inherits a constructor from ConfidentialInfoManager::Core

Instance Method Details

#load(file_path) ⇒ Hash

JSON file load

Parameters:

  • file_path (String)

Returns:

  • (Hash)


20
21
22
# File 'lib/confidential_info_manager/json.rb', line 20

def load(file_path)
  decrypt_only_value(::JSON.parse(File.read(file_path), { symbolize_names: true }))
end

#save(secret_data, file_path) ⇒ Object

JSON file save

Parameters:

  • secret_data (Object)

    @note Object is a String or Array or Hash

  • file_path (String)


12
13
14
# File 'lib/confidential_info_manager/json.rb', line 12

def save(secret_data, file_path)
  File.open(file_path, "w") { |file| file.write(::JSON.pretty_generate(encrypt_only_value(secret_data))) }
end