Sha256: c2a4bcd470c864aca2fe31e2b947268a91fbaf13ec854910e33677374922747e

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

require File.dirname(__FILE__) + '/spec_helper.rb'

describe 'Yubikey::Modhex' do
  it 'should decode modhex' do
    Yubikey::ModHex.decode('hknhfjbrjnlnldnhcujvddbikngjrtgh').should == "i\266H\034\213\253\242\266\016\217\"\027\233X\315V"
    Yubikey::ModHex.decode('urtubjtnuihvntcreeeecvbregfjibtn').should == "\354\336\030\333\347o\275\f33\017\0345Hq\333"
    
    Yubikey::ModHex.decode('dteffuje').should == "-4N\203"
    
    Yubikey::ModHex.decode('ifhgieif').should == 'test'
    Yubikey::ModHex.decode('hhhvhvhdhbid').should == 'foobar'
    
    Yubikey::ModHex.decode('cc').should == "\000"
  end
  
  it 'should raise if modhex string length uneven' do
    lambda { Yubikey::ModHex.decode('ifh') }.should raise_error(ArgumentError)
  end
  
  it 'should encode modhex' do
    Yubikey::ModHex.encode("i\266H\034\213\253\242\266\016\217\"\027\233X\315V").should == 'hknhfjbrjnlnldnhcujvddbikngjrtgh'
    Yubikey::ModHex.encode("\354\336\030\333\347o\275\f33\017\0345Hq\333").should == 'urtubjtnuihvntcreeeecvbregfjibtn'
    
    Yubikey::ModHex.encode("-4N\203").should == 'dteffuje'
    
    Yubikey::ModHex.encode('test').should == 'ifhgieif'
    Yubikey::ModHex.encode('foobar').should == 'hhhvhvhdhbid'
    
    Yubikey::ModHex.encode("\000").should == 'cc'
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
titanous-yubikey-1.0.2 spec/yubikey_modhex_spec.rb
titanous-yubikey-1.1.0 spec/yubikey_modhex_spec.rb
titanous-yubikey-1.1.1 spec/yubikey_modhex_spec.rb
yubikey-1.2.1 spec/yubikey_modhex_spec.rb
yubikey-1.2.0 spec/yubikey_modhex_spec.rb
yubikey-1.1.1 spec/yubikey_modhex_spec.rb
yubikey-1.1.0 spec/yubikey_modhex_spec.rb
yubikey-1.0.2 spec/yubikey_modhex_spec.rb