Sha256: ba3ee6e0fa2c8de1b414b9fafea8c83cfc5a5441d1cf14b2b023a30034bee8b3

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

# encoding: binary
require 'spec_helper'

RSpec.describe RbNaCl::Hash::Blake2b do
  let(:reference_string)      { vector :blake2b_message }
  let(:reference_string_hash) { vector :blake2b_digest }
  let(:empty_string_hash)     { vector :blake2b_empty }

  it "calculates the correct hash for a reference string" do
    expect(RbNaCl::Hash.blake2b(reference_string)).to eq reference_string_hash
  end

  it "calculates the correct hash for an empty string" do
    expect(RbNaCl::Hash.blake2b("")).to eq empty_string_hash
  end

  context "keyed" do
    let(:reference_string)      { vector :blake2b_keyed_message }
    let(:reference_key)         { vector :blake2b_key }
    let(:reference_string_hash) { vector :blake2b_keyed_digest }

    it "calculates keyed hashes correctly" do
      expect(RbNaCl::Hash.blake2b(reference_string, key: reference_key)).to eq reference_string_hash
    end

    it "doesn't accept empty strings as a key" do
      expect { RbNaCl::Hash.blake2b(reference_string, key: "") }.to raise_exception
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rbnacl-3.1.2 spec/rbnacl/hash/blake2b_spec.rb