MCPcopy Index your code
hub / github.com/secdev/scapy / RandBin

Class RandBin

scapy/volatile.py:546–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544
545
546class RandBin(_RandString[bytes]):
547 _DEFAULT_CHARS = b"".join(chb(c) for c in range(256))
548
549 def __init__(self, size=None, chars=_DEFAULT_CHARS):
550 # type: (Optional[Union[int, RandNum]], bytes) -> None
551 if size is None:
552 size = RandNumExpo(0.01)
553 self.size = size
554 self.chars = chars
555
556 def _command_args(self):
557 # type: () -> str
558 if not isinstance(self.size, VolatileValue):
559 return "size=%r" % self.size
560
561 if isinstance(self.size, RandNumExpo) and \
562 self.size.lambd == 0.01 and self.size.base == 0:
563 # Default size for RandString, skip
564 return ""
565 return "size=%r" % self.size.command()
566
567 def _fix(self):
568 # type: () -> bytes
569 s = b""
570 for _ in range(int(self.size)):
571 s += struct.pack("!B", random.choice(self.chars))
572 return s
573
574
575class RandTermString(RandBin):

Callers 15

randvalMethod · 0.90
randvalMethod · 0.90
randvalMethod · 0.90
randvalMethod · 0.90
randvalMethod · 0.90
in6_getRandomizedIfaceIdFunction · 0.90
CGA_ParamsClass · 0.90
randvalMethod · 0.90
randvalMethod · 0.90
gen_nonceMethod · 0.90
__init__Method · 0.90

Calls 2

chbFunction · 0.90
joinMethod · 0.80

Tested by

no test coverage detected