Yubikey
A Ruby library for verifying, decoding, decrypting and parsing Yubikey one-time passwords.
Install / Use
/learn @titanous/YubikeyREADME
yubikey
Description
A library to verify, decode, decrypt and parse Yubikey one-time passwords.
Usage
OTP Decryption
key = 'ecde18dbe76fbd0c33330f1c354871db'
otp = 'dteffujehknhfjbrjnlnldnhcujvddbikngjrtgh'
token = Yubikey::OTP.new(otp, key)
p "Device public id: #{token.public_id}" #=> 'dteffuje'
p "Device secret id: #{token.secret_id}" #=> '8792ebfe26cc'
p "Device insertions: #{token.insert_counter}" #=> 19
p "Session activation counter: #{token.session_counter}" #=> 17
p "Session timestamp: #{token.timestamp}" #=> 49712
p "OTP random data: #{token.random_number}" #=> 40904
OTP Verification
Use your own api_key and api_id, which you can get at yubico.com.
begin
otp = Yubikey::OTP::Verify.new(:api_id => 1234,
:api_key => 'NiSwGZBQ0gTbwXbRGWAf4kM5xXg=',
:otp => 'dteffujehknhfjbrjnlnldnhcujvddbikngjrtgh')
if otp.valid?
p 'valid OTP'
elsif otp.replayed?
p 'replayed OTP'
end
rescue Yubikey::OTP::InvalidOTPError
p 'invalid OTP'
end
Install
Yubikey is available as a gem, to install it just install the gem:
gem install yubikey
If you're using Bundler, add the gem to Gemfile.
gem 'yubikey'
Then run bundle install.
Copyright
Ruby library
Written by Jonathan Rudenberg. Copyright (c) 2009 Jonathan Rudenberg
The MIT License. See LICENSE.
Contributors
Related Skills
node-connect
349.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。

