pylibswarm

Python3 wrapper for libswarm-ng
git clone git://git.defalsify.org/pylibswarm.git
Log | Files | Refs | Submodules | README | LICENSE

soc.py (279B)


      1 def from_str(s, target_length, label):
      2     if len(s) > target_length:
      3         raise ValueError('{} value {} exceeded max length {}'.format(label, s, target_length))
      4     b = s.encode('utf-8')
      5     fmt = '{' + ':<0{}s'.format(target_length * 2) + '}'
      6     return fmt.format(b.hex())