lib/rotp/otp.rb
# Turns an integer to the OATH specified
# bytestring, which is fed to the HMAC
# along with the secret
#
Turns an integer to the OATH specified
bytestring, which is fed to the HMAC
along with the secret
Turns an integer to the OATH specified bytestring which is fed to the HMAC along with the secret
def int_to_bytestring(int, padding = 8)
      unless int >= 0
        raise ArgumentError, '#int_to_bytestring requires a positive number'
      end
      result = []
      until int == 0
        result << (int & 0xFF).chr
        int >>= 8
      end
      result.reverse.join.rjust(padding, 0.chr)
    end
def int_to_bytestring ( int , padding = 8 ) unless int >= 0 raise ArgumentError , '#int_to_bytestring requires a positive number' end result = [ ] until int == 0 result << ( int & 0xFF ) . chr int >>= 8 end result . reverse . join . rjust ( padding , 0 . chr ) end
Turns an integer to the OATH specified
bytestring, which is fed to the HMAC
along with the secret
Turns an integer to the OATH specified bytestring which is fed to the HMAC along with the secret
int
<not_specific>
padding
<not_specific>