class BlockChyp::CryptoUtils

crypto and encoding utilities

Public Class Methods

bin2hex(val) click to toggle source
# File lib/crypto_utils.rb, line 17
def self.bin2hex(val)
  val.each_byte.map { |b| b.to_s(16) }.join
end
generate_nonce() click to toggle source
# File lib/crypto_utils.rb, line 9
def self.generate_nonce
  bin2hex(SecureRandom.bytes(32))
end
hex2bin(val) click to toggle source
# File lib/crypto_utils.rb, line 21
def self.hex2bin(val)
  val.scan(/../).map { |x| x.hex.chr }.join
end
timestamp() click to toggle source
# File lib/crypto_utils.rb, line 13
def self.timestamp
  Time.now.utc.to_datetime.rfc3339
end