Giter Site home page Giter Site logo

yubioath's Introduction

YubiOATH

A mostly-complete Ruby implementation of the YubiOATH applet protocol.

Usage

The YubiOATH class accepts a card, which must respond to #transmit(apdu). See costan/smartcard for more info.

yubioath = YubiOATH.new(card)

yubioath.put(name: 'foo', secret: '123456')            # => true
yubioath.calculate(name: 'foo', timestamp: Time.now)   # => '237846'

yubioath.put(name: 'bar', secret: '345678')   # => true
yubioath.put(name: 'qux', secret: '567890')   # => true
yubioath.list.keys                            # => ['foo', 'bar', 'qux']
yubioath.calculate_all(timestamp: Time.now)   # => {'foo' => '234526', 'bar' => '293857', 'qux' => '934856'}

yubioath.delete('qux')   # => true
yubioath.list.keys   # => ['foo', 'bar']

yubioath.reset        # => true
yubioath.list.empty?  # => true

Instructions

You can also trigger the instructions by instantiating the relevant class with a card and invoking its #call method.

calculate = YubiOATH::Calculate.new(card)
calculate_all = YubiOATH::CalculateAll.new(card)
delete = YubiOATH::Delete.new(card)
list = YubiOATH::List.new(card)
put = YubiOATH::Put.new(card)
reset = YubiOATH::Reset.new(card)

put.call(name: 'foo', secret: '123456')            # => true
calculate.call(name: 'foo', timestamp: Time.now)   # => '237846'

put.call(name: 'bar', secret: '345678')   # => true
put.call(name: 'qux', secret: '567890')   # => true
list.call.keys                            # => ['foo', 'bar', 'qux']
calculate_all.call(timestamp: Time.now)   # => {'foo' => '234526', 'bar' => '293857', 'qux' => '934856'}

delete.call('qux')   # => true
list.call.keys   # => ['foo', 'bar']

reset.call        # => true
list.call.empty?  # => true

yubioath's People

Contributors

jamesottaway avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.