sodium.cr/src/sodium/key.cr

20 lines
286 B
Crystal
Raw Normal View History

require "./wipe"
module Sodium
2017-07-12 05:13:52 +02:00
abstract class Key
include Sodium::Wipe
2017-07-12 05:13:52 +02:00
abstract def bytes
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