Class: ActionPushWeb::VapidKeyGenerator
- Inherits:
-
Object
- Object
- ActionPushWeb::VapidKeyGenerator
- Defined in:
- lib/action_push_web/vapid_key_generator.rb
Instance Method Summary collapse
-
#initialize ⇒ VapidKeyGenerator
constructor
A new instance of VapidKeyGenerator.
- #private_key ⇒ Object
- #public_key ⇒ Object
Constructor Details
#initialize ⇒ VapidKeyGenerator
Returns a new instance of VapidKeyGenerator.
3 4 5 |
# File 'lib/action_push_web/vapid_key_generator.rb', line 3 def initialize @ec_key = OpenSSL::PKey::EC.generate("prime256v1") end |
Instance Method Details
#private_key ⇒ Object
7 8 9 |
# File 'lib/action_push_web/vapid_key_generator.rb', line 7 def private_key Base64.urlsafe_encode64(ec_key.private_key.to_s(2)) end |
#public_key ⇒ Object
11 12 13 |
# File 'lib/action_push_web/vapid_key_generator.rb', line 11 def public_key Base64.urlsafe_encode64(ec_key.public_key.to_bn.to_s(2)) end |