Ask Your Question
0

How to enter a multiprecision integer in hex big endian

asked 13 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 13 years ago

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

Preview: (hide)
link

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: 13 years ago

Seen: 4,232 times

Last updated: Jan 29 '12