CkByteData CkPython Reference Documentation
CkByteData
Current Version: 10.0.0
Represents a chunk of byte data and provides methods for accessing it, adding to it, or saving and loading from files.
Object Creation
obj = chilkat.CkByteData()
Properties
SecureClear
boolVal = ckByteData.get_SecureClear();
ckByteData.put_SecureClear(boolVal);
If set to True, then memory is always first overwritten with zero bytes prior to deallocation. The default value of this property is False.
topMethods
append
ckByteData.append(db);
Appends byte data to the data already contained in the object.
topappend2
# szByteData is an integer
ckByteData.append2(pByteData, szByteData);
Appends bytes to the data already contained in the object.
topappendChar
ckByteData.appendChar(ch);
Appends a single byte.
topappendCharN
# numTimes is an integer
ckByteData.appendCharN(ch, numTimes);
Appends a single char N times. The equivalent of calling appendChar N times.
topappendEncoded
# encoding is a string
ckByteData.appendEncoded(str, encoding);
Appends binary data from an encoded string. The encoding can be specified as "hex", "base64", "url", "quoted-printable", "modBase64", "base58", or "base32". The input string is decoded from the specified encoding and the binary data is appended to the calling object's content.
topappendEncodedW
# encoding is a utf-16 string
ckByteData.appendEncodedW(str, encoding);
To be documented soon...
topappendFile
retBool = ckByteData.appendFile(path);
Opens a file for binary read, appends the file contents, and closes the file.
topappendFileW
retBool = ckByteData.appendFileW(path);
Opens a file for binary read, appends the file contents, and closes the file.
topappendInt
# littleEndian is a boolean
ckByteData.appendInt(intValue, littleEndian);
Appends a 32-bit signed integer (4 bytes) to the data already contained in the object. littleEndian determines whether the big endian or little endian byte ordering is used.
topappendRandom
ckByteData.appendRandom(numBytes);
Appends numBytes random bytes to the data already contained within the object.
topappendRange
# index is an integer
# numBytes is an integer
ckByteData.appendRange(byteData, index, numBytes);
Appends a range of bytes from byteData to the data contained withing the caller. The first byte is at index 0.
topappendShort
# littleEndian is a boolean
ckByteData.appendShort(shortValue, littleEndian);
Appends a 16-bit signed integer (2 bytes) to the data already contained in the object. littleEndian determines whether the big endian or little endian byte ordering is used.
topappendStr
ckByteData.appendStr(str);
Appends a null-terminated string to the data, without including the terminating null.
topappendStrW
# charset is a utf-16 string
ckByteData.appendStrW(str, charset);
To be documented soon...
topbeginsWith
retBool = ckByteData.beginsWith(byteDataObj);
Returns True if the caller's data begins with the exact bytes contained within byteDataObj.
topbeginsWith2
# szByteData is an integer
retBool = ckByteData.beginsWith2(pByteData, szByteData);
Returns True if the caller's data begins with specified bytes.
topbyteSwap4321
4321 byte swaps the data contained within the object.
topclear
Clears the CkByteData object of all data. The internal memory is deallocated. To clear without deallocating, call dropData instead.
topdropData
Sets the size of the data to 0. Does not deallocate the existing internal buffer. (This is a fast way of "clearing" the CkByteData object, such that the existing data remains in memory and is overwritten on the next append.)
If the SecureClear property is set to True, then the internal memory buffer is zeroed out before resetting the size to 0.
topencode
Encodes binary data according to the encoding requested. The encoding can be specified as "hex", "base64", "url", "quoted-printable", "modBase64", "base58", "base32", "qp-
encodeW
To be documented soon...
topensureBuffer
status = ckByteData.ensureBuffer(expectedNumBytes);
This method can be called to help optimize internal memory re-allocation. If, for example, many calls will be made to append data, and the total size is approximately known, then this method can be called to pre-allocate the internal buffer to the expected total size.
If the internal buffer is already larger than the expectedNumBytes then nothing happens. The existing internal buffer is kept.
Returns True for success, False for failure.
topequals
retBool = ckByteData.equals(compareBytes);
Returns True if compareBytes contains exactly the same content as the caller. Otherwise returns False.
topequals2
# numBytes is an integer
retBool = ckByteData.equals2(pCompareBytes, numBytes);
Returns True if the bytes pointed to by pCompareBytes contains exactly the same content as the caller. Otherwise returns False.
topfindBytes
retInt = ckByteData.findBytes(byteDataObj);
Locates the first occurrence of the bytes contained in byteDataObj and returns the index of where these bytes occur in the caller's data. Returns -1 if not found.
topfindBytes2
# findBytesLen is an integer
retInt = ckByteData.findBytes2(findBytes, findBytesLen);
Locates the first occurrence of the specified bytes and returns the index of where these bytes occur in the caller's data. Returns -1 if not found.
topgetByte
retByte = ckByteData.getByte(byteIndex);
Returns the Nth byte of the binary data. The 1st byte is at index 0.
topgetChar
retChar = ckByteData.getChar(byteIndex);
Returns the Nth byte of the binary content as a "char". The 1st byte is at index 0.
topgetData
Returns a pointer to the internal buffer. Be careful with this method because if additional data is appended, the data within the object may be relocated and the pointer may cease to be valid.
topgetDataAt
binary_data = ckByteData.getDataAt(byteIndex);
Same as getData, except it gets a pointer to the data at a byte offset. (0 = the start of buffer)
topgetEncodedW
utf16_text = ckByteData.getEncodedW(encoding);
The utf-16 version of getEncoded.
topgetInt
retInt = ckByteData.getInt(byteIndex);
Returns the 4-byte integer located at a specific byte index.
topgetRange
# numBytes is an integer
binary_data = ckByteData.getRange(byteIndex, numBytes);
Copies a range of bytes to a separate internal memory buffer and returns the pointer to the bytes. The returned pointer is only valid while the object exists. Also, any subsequent calls to getRange, getRangeStr, or to_s will invalidate the buffer.
topgetSize
Returns the number of bytes in the data buffer.
topis7bit
Returns True if all the bytes are in the range 0x00 to 0x7F.
toploadFile
retBool = ckByteData.loadFile(path);
Equivalent to clear() followed by appendFile().
toploadFileW
retBool = ckByteData.loadFileW(path);
To be documented soon...
toppad
# paddingScheme is an integer
ckByteData.pad(blockSize, paddingScheme);
Pads the data to a multiple of the blockSize using a cryptographic padding scheme specified by paddingScheme. The possible integer values for paddingScheme are the same as those listed for the PaddingScheme property of the CkCrypt2 class.
topremoveChunk
# numBytes is an integer
ckByteData.removeChunk(startIndex, numBytes);
Removes (discards) a range from the data.
topreplaceChar
# replacementByteValue is a byte
ckByteData.replaceChar(existingByteValue, replacementByteValue);
Replaces all occurrences of existingByteValue with replacementByteValue.
topsaveFile
retBool = ckByteData.saveFile(path);
Saves the byte data to a file. If the file already exists, it will be overwritten.
topsaveFileW
retBool = ckByteData.saveFileW(path);
To be documented soon...
topshorten
ckByteData.shorten(numBytes);
Discards N bytes from the end of the data.
topto_ws
utf16_text = ckByteData.to_ws(charset);
To be documented soon...
topunpad
# paddingScheme is an integer
ckByteData.unpad(blockSize, paddingScheme);
Unpads the data from a multiple of the blockSize to the original data size using a cryptographic padding scheme specified by paddingScheme. The possible integer values for paddingScheme are the same as those listed for the PaddingScheme property of the CkCrypt2 class.
top