Class: Trocla::Formats::Pgsql

Inherits:
Base
  • Object
show all
Defined in:
lib/trocla/formats/pgsql.rb

Instance Attribute Summary

Attributes inherited from Base

#trocla

Instance Method Summary collapse

Methods inherited from Base

expensive, #expensive?, expensive?, #initialize, #render

Constructor Details

This class inherits a constructor from Trocla::Formats::Base

Instance Method Details

#format(plain_password, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/trocla/formats/pgsql.rb', line 5

def format(plain_password, options = {})
  encode = (options['encode'] || 'sha256')
  case encode
  when 'md5'
    raise 'You need pass the username as an option to use this format' unless options['username']

    'md5' + Digest::MD5.hexdigest(plain_password + options['username'])
  when 'sha256'
    pg_sha256(plain_password)
  else
    raise 'Unkmow encode %s for pgsql password' % [encode]
  end
end