YubikeyOTP.ModHex (YubikeyOTP v0.2.1) View Source
Implementation of ModHex encoding and decoding.
Link to this section Summary
Functions
Decodes the given modhex into a binary string.
Decodes the given modhex into a binary string.
Encodes the binary string to modhex.
Determines whether the given string is hexadecimal.
Converts the given hexadecimal string to modhex.
Determines whether the given string is modhex.
The digits in modhex
Converts the given modhex string to hexadecimal.
Link to this section Functions
Specs
Decodes the given modhex into a binary string.
An ArgumentError
exception is raised if the value is not modhex.
Examples
iex> YubikeyOTP.ModHex.decode("jjnkec")
{:ok, <<0x88, 0xb9, 0x30>>}
iex> YubikeyOTP.ModHex.decode("nope")
:error
Specs
Decodes the given modhex into a binary string.
An ArgumentError
exception is raised if the value is not modhex.
Examples
iex> YubikeyOTP.ModHex.decode!("jjnkec")
<<0x88, 0xb9, 0x30>>
Specs
Encodes the binary string to modhex.
Examples
iex> YubikeyOTP.ModHex.encode(<<0x88, 0xb9, 0x30>>)
"jjnkec"
Specs
Determines whether the given string is hexadecimal.
Examples
iex> YubikeyOTP.ModHex.hex?("666f6F626172")
true
iex> YubikeyOTP.ModHex.hex?("nope")
false
Specs
Converts the given hexadecimal string to modhex.
An ArgumentError
exception is raised if the value is not hex.
Examples
iex> YubikeyOTP.ModHex.hex_to_modhex!("88b930")
"jjnkec"
iex> YubikeyOTP.ModHex.hex_to_modhex!("88B930")
"jjnkec"
Specs
Determines whether the given string is modhex.
Examples
iex> YubikeyOTP.ModHex.modhex?("jjnkec")
true
iex> YubikeyOTP.ModHex.modhex?("nope")
false
The digits in modhex
Specs
Converts the given modhex string to hexadecimal.
An ArgumentError
exception is raised if the value is not modhex.
Examples
iex> YubikeyOTP.ModHex.to_hex!("jjnkec")
"88b930"