2019-06-30 02:21:00 +02:00
|
|
|
require "./wipe"
|
|
|
|
|
2019-06-29 01:17:09 +02:00
|
|
|
module Sodium
|
2017-07-12 05:13:52 +02:00
|
|
|
abstract class Key
|
2019-06-30 02:21:00 +02:00
|
|
|
include Sodium::Wipe
|
|
|
|
|
2017-07-12 05:13:52 +02:00
|
|
|
abstract def bytes
|
|
|
|
|
2019-06-28 02:35:31 +02:00
|
|
|
delegate to_slice, to: @bytes
|
2017-07-12 05:13:52 +02:00
|
|
|
|
|
|
|
def to_base64
|
|
|
|
Base64.encode(bytes)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.from_base64(encoded_key)
|
|
|
|
new(Base64.decode(encoded_key))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|