conversion

Date:

Jul 5, 2011

Authors:

Gary Belvin

This class facilitates conversion between domain spaces

class conversion.Conversion[source]

Bases: object

The goal is to convert arbitrarily between any of the following types

Input types:

  • bytes

  • Bytes

  • int

  • Integer Element

  • Modular Integer Element

Output types:

  • int

  • Group element

  • Integer element

  • Integer element mod N

classmethod IP2OS(number, xLen=None)[source]
Parameters:
  • number: is a normal integer, not modular

  • xLen: is the intended length of the resulting octet string

Converts an integer into a byte string

classmethod OS2IP(bytestr, element=False)[source]
Return:

A python int if element is False. An integer.Element if element is True

Converts a byte string to an integer

classmethod bytes2element(bytestr)[source]

Converts a byte string to a group element

classmethod bytes2integer(bytestr)[source]

Converts a bytes string to an integer object

classmethod bytes2str(byteobj)[source]
classmethod int2bin(intobj)[source]
classmethod str2bytes(strobj)[source]