import
chilkat
data
=
chilkat.CkByteData()
data.append(
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09'
,
10
)
# These are the padding options for the "pad" method:
# 0 = Each padding byte is the pad count (16 extra added if size is already a multiple of 16)
# 1 = Random bytes except the last is the pad count (16 extra added if size is already multiple of 16)
# 2 = Pad with random data. (If already a multiple of 16, no padding is added).
# 3 = Pad with NULLs. (If already a multiple of 16, no padding is added).
# 4 = Pad with SPACE chars(0x20). (If already a multiple of 16, no padding is added).
# We'll pad to a block size of 16 bytes.
blockSize
=
16
paddingScheme
=
0
# Pad, display the padded byte data, unpad, then re-display
data.pad(blockSize,paddingScheme)
print
data.getEncoded(
"hex"
)
data.unpad(
16
,paddingScheme)
print
data.getEncoded(
"hex"
)
print
"----"
paddingScheme
=
1
# Pad, display the padded byte data, unpad, then re-display
data.pad(blockSize,paddingScheme)
print
data.getEncoded(
"hex"
)
data.unpad(
16
,paddingScheme)
print
data.getEncoded(
"hex"
)
print
"----"
# There is no unpadding with schemes 2,3, and 4
data2
=
chilkat.CkByteData()
data2.append(
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09'
,
10
)
paddingScheme
=
2
# Pad and display the padded byte data
data2.pad(blockSize,paddingScheme)
print
data2.getEncoded(
"hex"
)
print
"----"
# There is no unpadding with schemes 2,3, and 4
data3
=
chilkat.CkByteData()
data3.append(
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09'
,
10
)
paddingScheme
=
3
# Pad and display the padded byte data
data3.pad(blockSize,paddingScheme)
print
data3.getEncoded(
"hex"
)
print
"----"
# There is no unpadding with schemes 2,3, and 4
data4
=
chilkat.CkByteData()
data4.append(
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09'
,
10
)
paddingScheme
=
4
# Pad and display the padded byte data
data4.pad(blockSize,paddingScheme)
print
data4.getEncoded(
"hex"
)
print
"----"