Module: Blake2b

Extended by:
FFI::Library
Defined in:
lib/blake2b.rb,
lib/blake2b/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
"0.1.4"

Class Method Summary collapse

Class Method Details

.blake2b160(u8a) ⇒ Object



29
30
31
# File 'lib/blake2b.rb', line 29

def self.blake2b160(u8a)
  self.hex(u8a, 20)
end

.blake2b256(u8a) ⇒ Object



33
34
35
# File 'lib/blake2b.rb', line 33

def self.blake2b256(u8a)
  self.hex(u8a, 32)
end

.blake2b512(u8a) ⇒ Object



37
38
39
# File 'lib/blake2b.rb', line 37

def self.blake2b512(u8a)
  self.hex(u8a, 64)
end

.hex(u8a, out_len = 32) ⇒ Object



22
23
24
25
26
27
# File 'lib/blake2b.rb', line 22

def self.hex(u8a, out_len=32)
  c = FFI::MemoryPointer.new(:int8, u8a.size)
  c.write_array_of_int8 u8a

  self.rust_blake2b(c, c.size, out_len).to_s
end