module CryptBufferConcern::Convertable
Public Instance Methods
base64(strict: true)
click to toggle source
# File lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb, line 27 def base64(strict: true) strict ? Base64.strict_encode64(str) : Base64.encode64(str) end
bits()
click to toggle source
# File lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb, line 19 def bits map{|b| "%08d" % b.to_s(2) } end
chars()
click to toggle source
# File lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb, line 9 def chars map(&:chr) end
Also aliased as: c
hex()
click to toggle source
# File lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb, line 3 def hex bytes2hex(bytes).upcase end
Also aliased as: h
str()
click to toggle source
# File lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb, line 14 def str map(&:chr).join end
Also aliased as: s
to_crypt_buffer()
click to toggle source
# File lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb, line 31 def to_crypt_buffer self end
to_s()
click to toggle source
# File lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb, line 23 def to_s str end
Private Instance Methods
bytes2hex(bytes)
click to toggle source
# File lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb, line 35 def bytes2hex(bytes) bytes.map{|b| b.to_s(16)}.map{|hs| hs.length == 1 ? "0#{hs}" : hs }.join end