Ask Your Question
0

How to enter a multiprecision integer in hex big endian

asked 2012-01-29 13:50:05 +0100

anonymous user

Anonymous

Hi,

I have a multiprecision integer (retrieved from a gpg signature). Example:

DSA p(2048 bits) - ab 21 99 ...many bytes here ... 5b

How can I enter the hex representation into Sage to work with it?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-01-29 15:21:59 +0100

tbender gravatar image

Found the answer in IRC (thanks, saraedum, few_)

p = ZZ('0x2199 ... 5b')

If the number is pretty big you could also read it from a file:

f = open('/tmp/p.txt')
p = ZZ('0x' + f.read())
f.close()

This assumes that you have a file p.txt containing the hex string with the whitespaces stripped.

hope that helps

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-01-29 13:50:05 +0100

Seen: 4,189 times

Last updated: Jan 29 '12