2010-02-09 23:46:49 +01:00
|
|
|
module Net
|
|
|
|
class LDAP
|
|
|
|
module Extensions
|
|
|
|
module Bignum
|
|
|
|
|
|
|
|
def to_ber
|
2010-02-12 14:39:57 +01:00
|
|
|
# NOTE: Array#pack's 'w' is a BER _compressed_ integer. We need uncompressed
|
|
|
|
# BER integers, so we're not using that.
|
|
|
|
# See also: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/228864
|
|
|
|
result = []
|
2010-02-09 23:46:49 +01:00
|
|
|
|
2010-02-12 14:39:57 +01:00
|
|
|
n = self
|
|
|
|
while n>0
|
|
|
|
b = n & 0xff
|
|
|
|
result << b
|
|
|
|
n = n >> 8
|
2010-02-09 23:46:49 +01:00
|
|
|
end
|
|
|
|
|
2010-02-12 14:39:57 +01:00
|
|
|
"\002" + ([result.size] + result.reverse).pack('C*')
|
2010-02-09 23:46:49 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|