Module: Rex::Proto::Kademlia::Util
- Defined in:
- lib/rex/proto/kademlia/util.rb
Class Method Summary collapse
-
.decode_peer_id(bytes) ⇒ String
Decodes an on-the-wire representation of a Kademlia peer to its 16-character hex equivalent.
Class Method Details
.decode_peer_id(bytes) ⇒ String
Decodes an on-the-wire representation of a Kademlia peer to its 16-character hex equivalent
10 11 12 13 14 15 |
# File 'lib/rex/proto/kademlia/util.rb', line 10 def self.decode_peer_id(bytes) peer_id = 0 return nil unless bytes.size == 16 bytes.unpack('VVVV').map { |p| peer_id = ((peer_id << 32) ^ p) } peer_id.to_s(16).upcase end |