classmethod galois.Poly.Int(integer: int, field: = None) Self

Constructs a polynomial over $$\mathrm{GF}(p^m)$$ from its integer representation.

Parameters:
integer: int

The integer representation of the polynomial $$f(x)$$.

field: = None

The Galois field $$\mathrm{GF}(p^m)$$ the polynomial is over. The default is None which corresponds to GF2.

Returns:

The polynomial $$f(x)$$.

Int() and __int__() are inverse operations.

Examples

Construct a polynomial over $$\mathrm{GF}(2)$$ from its integer representation.

In : f = galois.Poly.Int(5); f
Out: Poly(x^2 + 1, GF(2))

In : int(f)
Out: 5


Construct a polynomial over $$\mathrm{GF}(3^5)$$ from its integer representation.

In : GF = galois.GF(3**5)

In : f = galois.Poly.Int(186535908, field=GF); f
Out: Poly(13x^3 + 117, GF(3^5))

In : int(f)
Out: 186535908

# The polynomial/integer equivalence
In : int(f) == 13*GF.order**3 + 117
Out: True


Construct a polynomial over $$\mathrm{GF}(2)$$ from its binary string.

In : f = galois.Poly.Int(int("0b1011", 2)); f
Out: Poly(x^3 + x + 1, GF(2))

In : bin(f)
Out: '0b1011'


Construct a polynomial over $$\mathrm{GF}(2^3)$$ from its octal string.

In : GF = galois.GF(2**3)

In : f = galois.Poly.Int(int("0o5034", 8), field=GF); f
Out: Poly(5x^3 + 3x + 4, GF(2^3))

In : oct(f)
Out: '0o5034'


Construct a polynomial over $$\mathrm{GF}(2^8)$$ from its hexadecimal string.

In : GF = galois.GF(2**8)

In : f = galois.Poly.Int(int("0xf700a275", 16), field=GF); f
Out: Poly(247x^3 + 162x + 117, GF(2^8))

In : hex(f)
Out: '0xf700a275'