Ask Your Question

Revision history [back]

I assume the binary string you want is the list of coefficients of a. For this, you could do the following:

  • Make an element:

    sage: K = GF(2^7,'a');
    sage: x = K.random_element(); x
    a^5 + a^4 + a^3 + a
  • Convert the element to a polynomial and get the list of coefficients:

    sage: x.polynomial().coeffs()
    [0, 1, 0, 1, 1, 1]
  • Go directly from the element to a string by joining the strings of the coefficients:

    sage: ''.join(map(str,x.polynomial().coeffs()))