Specifications
Constructs a new byte array by converting a source
string with the specified codec; see text encoding.
ByteArray ( source : String, codec :
String ) : ByteArray
Properties
The number of bytes in the byte array. This value is
read-only.
length : Number
size : Number
Member functions
Returns the value of the byte at the specified zero-based index
in the byte array. The returned value is an integer in the range
getAt( index : Number ) :
Number
[0..255]. An exception is thrown if the index is out of range or
if it is not an integer.
Stores a new value for the byte at the specified zero-based
index in the byte array. The specified value must be an integer
putAt( index : Number, value
: Number )
in the range [0..255]. An exception is thrown if the value or the
index are out of range, or if they are not integers.
Returns the specified portion of the byte array (zero-based start
index). An exception is thrown if the requested portion is out
of range, or if start and length are not integers.
getSubArray ( start : Number,
length : Number ) : ByteArray
Returns the string obtained by converting the byte array using
the specified codec, text encoding.
toString (codec : String ) :
String
Returns a new ByteArray which is the re-encoded version of
the current one. Supported codecs are Hex and Base64. This
convertTo (codec : String ) :
ByteArray
function recodes the entire ByteArray even if the data includes
null bytes.
Example: ByteArray (‘abc’, ‘UTF-8’).convertTo(‘Hex’) returns a
ByteArray of length 6 with bytes 54 49 54 50 54 51.
Signatures
The ByteArray class offers the following additional functions to generate and verify signatures
using standard RSA algorithms (compatible with PKCS#1 v2.0).
Returns the digital signature for the data in the receiving ByteArray using
the specified private key. This signature allows a receiver to verify that
generateSignature(
privateKeyPath :
String ) : ByteArray
the data was indeed generated by a script that has access to the specified
private key (assuming that the receiver has access to the public key
corresponding to the private key).
The privateKeyPath argument specifies the path to a private key file in
the standard PKCS #8 format. Since this format is not encrypted or
password protected, the user must provide other means to safeguard
the private key from inappropriate access.
411
Enfocus Switch 10










