Class: Fixnum

Inherits:
Object
  • Object
show all
Includes:
Crypto_math
Defined in:
lib/openid/util.rb

Instance Method Summary collapse

Methods included from Crypto_math

#mod_exp

Instance Method Details

#to_btwocObject

as a raw string.



34
35
36
37
38
39
# File 'lib/openid/util.rb', line 34

def to_btwoc
	bits = self.to_s(2)
	prepend = (8 - bits.length % 8) || (bits.index(/^1/) ? 8 : 0)
	bits = ('0' * prepend) + bits if prepend
	return [bits].pack('B*')
end