Module: Familia::Encryption::StrictBase64 Private
- Defined in:
- lib/familia/encryption/strict_base64.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Strict Base64 for encryption keys and envelope fields: no line feeds on encode, and decode rejects anything that is not strict Base64.
Core Ruby's Array#pack and String#unpack1 with the 'm0' directive do this, so familia does not need the base64 gem. The base64 library that ships with Ruby 3.2 and 3.3, and base64 gem versions 0.2.0 and 0.3.0, implement their strict methods with the same calls:
def strict_encode64(bin) [bin].pack("m0") end
def strict_decode64(str) str.unpack1("m0") end
Class Method Summary collapse
-
.decode(text) ⇒ String
private
The decoded bytes, in ASCII-8BIT.
-
.encode(bytes) ⇒ String
private
Base64 text without line feeds.
Class Method Details
.decode(text) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the decoded bytes, in ASCII-8BIT.
36 37 38 |
# File 'lib/familia/encryption/strict_base64.rb', line 36 def decode(text) text.unpack1('m0') end |
.encode(bytes) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Base64 text without line feeds.
29 30 31 |
# File 'lib/familia/encryption/strict_base64.rb', line 29 def encode(bytes) [bytes].pack('m0') end |