Sha256: d833e31bd4e9ef18f1e98baae257af60d2c519b1a76fd271cef9e4210c40d01e

Contents?: true

Size: 1.25 KB

Versions: 10

Compression:

Stored size: 1.25 KB

Contents

# encoding: binary
# frozen_string_literal: true

RSpec.describe RbNaCl::Hash do
  context "sha256" do
    let(:reference_string)      { vector :sha256_message }
    let(:reference_string_hash) { vector :sha256_digest }
    let(:empty_string_hash)     { vector :sha256_empty }

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

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

    it "doesn't raise on a null byte" do
      expect { RbNaCl::Hash.sha256("\0") }.to_not raise_error
    end
  end

  context "sha512" do
    let(:reference_string)      { vector :sha512_message }
    let(:reference_string_hash) { vector :sha512_digest }
    let(:empty_string_hash)     { vector :sha512_empty }

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

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

    it "doesn't raise on a null byte" do
      expect { RbNaCl::Hash.sha512("\0") }.to_not raise_error
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rbnacl-7.1.1 spec/rbnacl/hash_spec.rb
rbnacl-7.1.0 spec/rbnacl/hash_spec.rb
rbnacl-7.0.0 spec/rbnacl/hash_spec.rb
rbnacl-6.0.1 spec/rbnacl/hash_spec.rb
rbnacl-6.0.0 spec/rbnacl/hash_spec.rb
rbnacl-5.0.0 spec/rbnacl/hash_spec.rb
rbnacl-4.0.2 spec/rbnacl/hash_spec.rb
rbnacl-4.0.1 spec/rbnacl/hash_spec.rb
rbnacl-4.0.0 spec/rbnacl/hash_spec.rb
rbnacl-4.0.0.pre spec/rbnacl/hash_spec.rb