Module: KStor::Crypto::ASCIIArmor

Defined in:
lib/kstor/crypto/ascii_armor.rb

Overview

Encode and decode binary data to ASCII.

Class Method Summary collapse

Class Method Details

.decode(str) ⇒ String

Decode an ASCII-armored string back to raw data.

Parameters:

  • str (String)

    ASCII-armored string

Returns:

  • (String)

    raw string



21
22
23
# File 'lib/kstor/crypto/ascii_armor.rb', line 21

def decode(str)
  Base64.strict_decode64(str)
end

.encode(bytes) ⇒ String

ASCII-armor a String of bytes.

Parameters:

  • bytes (String)

    raw string

Returns:

  • (String)

    ASCII-armored string



13
14
15
# File 'lib/kstor/crypto/ascii_armor.rb', line 13

def encode(bytes)
  Base64.strict_encode64(bytes)
end