Module: Sdkey::Crypto::Encoding
- Defined in:
- lib/sdkey/crypto/encoding.rb
Overview
Base64 helpers (standard and URL-safe).
Class Method Summary collapse
Class Method Details
.base64_to_bytes(b64) ⇒ Object
15 16 17 18 19 |
# File 'lib/sdkey/crypto/encoding.rb', line 15 def base64_to_bytes(b64) normalized = b64.tr("-_", "+/") pad = (4 - (normalized.length % 4)) % 4 Base64.decode64(normalized + ("=" * pad)).b end |
.bytes_to_base64(data) ⇒ Object
11 12 13 |
# File 'lib/sdkey/crypto/encoding.rb', line 11 def bytes_to_base64(data) Base64.strict_encode64(data.b) end |