class Dinomischus::KeyFile

Public Class Methods

create(path, password = "") click to toggle source

Create the key file

# File lib/dinomischus/l_key.rb, line 11
def self.create(path, password = "")
  raise RuntimeError.new("鍵ファイルが既に存在します。#{path}") if File.exist?(path)
  password = SecureRandom.urlsafe_base64 if password.empty?
  hash = {"key": {"type": "sha256", "value": password}}
  File.open(path, 'w') do |f|
    YAML.dump(hash, f)
  end
  true
end
load_file(path) click to toggle source
# File lib/dinomischus/l_key.rb, line 21
def self.load_file(path)
  yml = YAML.load_file(path)
end