[Cryptography Team] Integer>>#asByteArray - "asn1 encoding"
Hans-Martin Mosner
hmm at heeg.de
Mon Dec 19 07:57:27 CET 2005
Chris Muller wrote:
>Does anyone mind if we rename this method to.. asAsn1Bytes or something?
>
>
I'd prefer a method name which says what it does, not in which context
it might be used.
So a method which converts an Integer into a big-endian ByteArray should
be called #asBigEndianByteArray, and the method to convert a big endian
ByteArray back into an Integer would probably be #asBigEndianInteger
(although I like that name less...).
A better alternative is probably to avoid representing ASN.1 Integers as
ByteArrays altogether. When they are read from a Stream, you can just
create an Integer, and when you're writing an Integer, you just write
its bytes to the stream without converting to a ByteArray. A
hypothetical class ASN1Stream should do that for you.
Cheers,
Hans-Martin
More information about the Cryptography
mailing list