module Crypto

Public Class Methods

blake2_128(bytes) click to toggle source
# File lib/common.rb, line 68
def self.blake2_128(bytes)
  Blake2b.hex bytes, 16
end
blake2_128_concat(bytes) click to toggle source
# File lib/common.rb, line 76
def self.blake2_128_concat(bytes)
  blake2_128(bytes) + bytes.bytes_to_hex[2..]
end
blake2_256(bytes) click to toggle source
# File lib/common.rb, line 72
def self.blake2_256(bytes)
  Blake2b.hex bytes, 32
end
identity(bytes) click to toggle source
# File lib/common.rb, line 44
def self.identity(bytes)
  bytes.bytes_to_hex[2..]
end
twox128(data) click to toggle source
# File lib/common.rb, line 54
def self.twox128(data)
  bytes = []
  2.times do |i|
    result = XXhash.xxh64 data, i
    bytes = bytes + result.to_s(16).rjust(16, '0').hex_to_bytes.reverse
  end
  bytes.bytes_to_hex[2..]
end
twox64(data) click to toggle source
# File lib/common.rb, line 48
def self.twox64(data)
  result = XXhash.xxh64 data, 0
  bytes = result.to_s(16).rjust(16, '0').hex_to_bytes.reverse
  bytes.bytes_to_hex[2..]
end
twox64_concat(bytes) click to toggle source
# File lib/common.rb, line 63
def self.twox64_concat(bytes)
  data = bytes.bytes_to_utf8
  twox64(data) + bytes.bytes_to_hex[2..]
end