|
/export/home/cpanrun/depot/main/contrib-patched/perl/CPAN/src/Encoding-BER/blib/html/site/lib/Encoding/BER.html |
$ber->add_implicit_tag('context', 'primitive', 'width-index', 42, 'integer');</PRE>
<P></P>
<DT><STRONG><A NAME="item_encode">encode( data )</A></STRONG><BR>
<DD>
BER encode the provided data. [see: ENCODING DATA]
<PRE>
example:
my $ber = $enc->encode( [0, 'public', [7.3, 0, 0, ['foo', 'bar']]] );</PRE>
<P></P>
<DT><STRONG><A NAME="item_decode">decode( ber )</A></STRONG><BR>
<DD>
Decode the provided BER encoded data. returns a perl data structure.
[see: DECODED DATA]
<PRE>
example:
my $data = $enc->decode( $ber );</PRE>
<P></P></DL>
<P>
<HR>
<H1><A NAME="encoding data">ENCODING DATA</A></H1>
<P>You can give data to the encoder in either of two ways (or mix and match).</P>
<P>You can specify simple values directly, and the module will guess the
correct tags to use. Things that look like integers will be encoded as
<CODE>integer</CODE>, things that look like floating-point numbers will be encoded
as <CODE>real</CODE>, things that look like strings, will be encoded as <CODE>octet_string</CODE>.
Arrayrefs will be encoded as <CODE>sequence</CODE>.</P>
<PRE>
example:
$enc->encode( [0, 1.2, "foobar", [ "baz", 37.94 ]] );</PRE>
<P>Alternatively, you can explicity specify the type using a hashref
containing <CODE>type</CODE> and <CODE>value</CODE> keys.</P>
<PRE>
example:
$enc->encode( { type => 'sequence',
value => [
{ type => 'integer',
value => 37 } ] } );</PRE>
<P>The type may be specfied as either a string containg the tag-name, or
as an arryref containing the class, type, and tag-name.</P>
<PRE>
example:
type => 'octet_string'
type => ['universal', 'primitive', 'octet_string']</PRE>
<P>Note: using the second form above, you can create wacky encodings
that no one will be able to decode.
</P>
<PRE>
The value should be a scalar value for primitive types, and an arrayref for constructed types.</PRE> <PRE> example: { type => 'octet_string', value => 'foobar' } { type => 'set', value => [ 1, 2, 3 ] }</PRE> <PRE> { type => ['universal', 'constructed', 'octet_string'], value => [ 'foo', 'bar' ] }</PRE> <P> <HR> <H1><A NAME=``decoded data''>DECODED DATA</A></H1> <P>The values returned from decoding will be similar to the way data to be encoded is specified, in the full long form. Additionally, the hashref will contain: <CODE>identval</CODE> the numeric value representing the class+type+tag and <CODE>tagnum</CODE> the numeric tag number.</P> <PRE> example: a string might be returned as: { type => ['universal', 'primitive', 'octet_string'], identval => 4, tagnum => 4, value => 'foobar', }</PRE> <P> <HR> <H1><A NAME=``tag names''>TAG NAME/A</H1> <P>The following are recognized as valid names of tags:</P> <PRE> bit_string bmp_string bool boolean character_string embedded_pdv enum enumerated external float general_string generalized_time graphic_string ia5_string int int32 integer integer32 iso646_string null numeric_string object_descriptor object_identifier octet_string oid printable_string real relative_object_identifier relative_oid roid sequence sequence_of set set_of string t61_string teletex_string uint uint32 universal_string universal_time unsigned_int unsigned_int32 unsigned_integer utf8_string videotex_string visible_string</PRE> <P> <HR> <H1><A NAME=``math::bigint''>Math::BigInt</A></H1> <P>If you have Math::BigInt, it can be used for large integers. If you want it used, you must load it yourself:</P> <PRE> use Math::BigInt; use Encoding::BER;</PRE> <P>It can be used for both encoding and decoding. The encoder can be handed either a Math::BigInt object, or a ``big string of digits'' marked as an integer:</P> <PRE> use math::BigInt;</PRE> <PRE> my $x = Math::BigInt->new( '12345678901234567890' ); $enc->encode( $x )</PRE> <PRE> $enc->encode( { type => 'integer', '12345678901234567890' } );</PRE> <P>During decoding, a Math::BigInt object will be created if the value ``looks big''.</P> <P></P> <PRE>
Yellowstone National Park
Encoding::BER::CER, Encoding::BER::DER
Encoding::BER::SNMP, Encoding::BER::Dumper
ITU-T x.690</PRE>
<PRE>
</BODY>
</HTML>
|
/export/home/cpanrun/depot/main/contrib-patched/perl/CPAN/src/Encoding-BER/blib/html/site/lib/Encoding/BER.html |