Sha256: a2427248448aae8eb13854233a05f1da146792968b4f71e729af0718ca6e4e92

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require_relative '_test_helper'

describe H::Generator do
  describe 'basic test' do
    before do
      @h = H::Generator.new('my-salt')
    end

    it 'returns a salted hash' do
      @h.input('', 44).must_equal 'rdOQxxmSfOy-3-HA7OrnqT2Pl2Y_I7Ojqsc1NwVP4sg='
    end

    it 'returns another salted hash' do
      @h.input('p@ssw0rd', 44).must_equal 'LCoF25LqK6yFMRs6OoQoZEI4GV4-gR7vd1' \
                                          'JZtbi8swA='
    end

    it 'returns a salted hash of 8 chars' do
      @h.input('p@ssw0rd', 8).must_equal 'LCoF25Lq'
    end
  end

  describe 'exotic test' do
    before do
      @h = H::Generator.new('塩')
    end

    it 'returns a different salted hash' do
      @h.input('p@ssw0rd', 44).wont_equal 'LCoF25LqK6yFMRs6OoQoZEI4GV4-gR7vd1' \
                                          'JZtbi8swA='
    end

    it 'returns a salted hash' do
      @h.input('シークレット', 44).must_equal '-q0zMnMSszj8D23a8aNJX_VYry9oSSLZ30Xl' \
                                        'HkmFt9I='
    end

    it 'returns a salted hash of 3 chars' do
      @h.input('シークレット', 3).must_equal '-q0'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
h-2.2.1 test/test_h.rb
h-2.2.0 test/test_h.rb