Sha256: e0c5e9a9005bb6e5cc5e0dc42fff34f1fdbb22b69ec131a0a346a82c371955e2

Contents?: true

Size: 910 Bytes

Versions: 3

Compression:

Stored size: 910 Bytes

Contents

require 'spec_helper'
require 'ronin/password'

describe Password do
  let(:password) { 'secret' }
  subject { Password.new(:clear_text => password) }

  it "should require a clear-text password" do
    pass = Password.new

    pass.should_not be_valid
  end

  describe "#digest" do
    let(:salt) { 'foo' }

    it "should calculate the digest of the password" do
      digest = subject.digest(:sha1)
      
      digest.should == Digest::SHA1.hexdigest(password)
    end

    it "should calculate the digest of the password and prepended salt" do
      digest = subject.digest(:sha1, :prepend_salt => salt)
      
      digest.should == Digest::SHA1.hexdigest(salt + password)
    end

    it "should calculate the digest of the password and appended salt" do
      digest = subject.digest(:sha1, :append_salt => salt)
      
      digest.should == Digest::SHA1.hexdigest(password + salt)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ronin-1.0.0.pre3 spec/password_spec.rb
ronin-1.0.0.pre2 spec/password_spec.rb
ronin-1.0.0.pre1 spec/password_spec.rb