本文整理匯總了Python中lastpass.parser.Parser類的典型用法代碼示例。如果您正苦於以下問題:Python Parser類的具體用法?Python Parser怎麽用?Python Parser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Parser類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setUp
def setUp(self):
self.key_iteration_count = 5000
self.blob = Blob(TEST_BLOB, self.key_iteration_count)
self.padding = 'BEEFFACE'
self.encryption_key = 'OfOUvVnQzB4v49sNh4+PdwIFb9Fr5+jVfWRTf+E2Ghg='.decode('base64')
self.chunks = Parser.extract_chunks(self.blob)
self.accounts = [Parser.parse_account(i, self.encryption_key) for i in self.chunks['ACCT']]
示例2: test_decode_aes256_cbc_plain_decodes_a_long_string
def test_decode_aes256_cbc_plain_decodes_a_long_string(self):
self.assertEqual(Parser.decode_aes256_cbc_plain(
'IcokDWmjOkKtLpZehWKL6666Uj6fNXPpX6lLWlou+1Lrwb+D3ymP6BAwd6C0TB3hSA=='.decode('base64'), self.encryption_key),
'All your base are belong to us')
示例3: test_decode_aes256_ecb_plain_decodes_a_short_string
def test_decode_aes256_ecb_plain_decodes_a_short_string(self):
self.assertEqual(Parser.decode_aes256_ecb_plain(
b64decode('8mHxIA8rul6eq72a/Gq2iw=='), self.encryption_key),
b'0123456789')
示例4: test_decode_aes256_auto_decodes_a_blank_string
def test_decode_aes256_auto_decodes_a_blank_string(self):
self.assertEqual(Parser.decode_aes256_auto('', self.encryption_key), '')
示例5: test_decode_hex_decodes_hex
def test_decode_hex_decodes_hex(self):
self.assertEqual(Parser.decode_hex(''), '')
self.assertEqual(Parser.decode_hex('00ff'), '\x00\xFF')
self.assertEqual(Parser.decode_hex('00010203040506070809'), '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09')
self.assertEqual(Parser.decode_hex('000102030405060708090a0b0c0d0e0f'), '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F')
self.assertEqual(Parser.decode_hex('8af633933e96a3c3550c2734bd814195'), '\x8A\xF6\x33\x93\x3E\x96\xA3\xC3\x55\x0C\x27\x34\xBD\x81\x41\x95')
示例6: test_read_payload_returns_a_payload
def test_read_payload_returns_a_payload(self):
io = StringIO(('FEEDDEADBEEF' + self.padding).decode('hex'))
self.assertEqual(Parser.read_payload(io, 6), 'FEEDDEADBEEF'.decode('hex'))
self.assertEqual(io.pos, 6)
示例7: test_skip_item_skips_a_non_empty_item
def test_skip_item_skips_a_non_empty_item(self):
io = StringIO(('00000004DEADBEEF' + self.padding).decode('hex'))
Parser.skip_item(io)
self.assertEqual(io.pos, 8)
示例8: test_read_chunk_returns_a_chunk
def test_read_chunk_returns_a_chunk(self):
io = StringIO(('4142434400000004DEADBEEF' + self.padding).decode('hex'))
self.assertEqual(Parser.read_chunk(io), Chunk('ABCD', 'DEADBEEF'.decode('hex')))
self.assertEqual(io.pos, 12)
示例9: test_read_uint32_returns_a_number
def test_read_uint32_returns_a_number(self):
io = BytesIO(codecs.decode('DEADBEEF' + self.padding, 'hex_codec'))
self.assertEqual(Parser.read_size(io), 0xDEADBEEF)
self.assertEqual(io.tell(), 4)
示例10: test_read_payload_returns_a_payload
def test_read_payload_returns_a_payload(self):
io = BytesIO(codecs.decode('FEEDDEADBEEF' + self.padding, 'hex_codec'))
self.assertEqual(Parser.read_payload(io, 6), codecs.decode('FEEDDEADBEEF', 'hex_codec'))
self.assertEqual(io.tell(), 6)
示例11: test_read_id_returns_an_id
def test_read_id_returns_an_id(self):
io = BytesIO(('ABCD' + self.padding).encode())
self.assertEqual(Parser.read_id(io), b'ABCD')
self.assertEqual(io.tell(), 4)
示例12: test_skip_item_skips_a_non_empty_item
def test_skip_item_skips_a_non_empty_item(self):
io = BytesIO(codecs.decode('00000004DEADBEEF' + self.padding, 'hex_codec'))
Parser.skip_item(io)
self.assertEqual(io.tell(), 8)
示例13: test_read_item_returns_an_item
def test_read_item_returns_an_item(self):
io = BytesIO(codecs.decode('00000004DEADBEEF' + self.padding, 'hex_codec'))
self.assertEqual(Parser.read_item(io), codecs.decode('DEADBEEF', 'hex_codec'))
self.assertEqual(io.tell(), 8)
示例14: test_read_chunk_returns_a_chunk
def test_read_chunk_returns_a_chunk(self):
io = BytesIO(codecs.decode('4142434400000004DEADBEEF' + self.padding, 'hex_codec'))
self.assertEqual(Parser.read_chunk(io), Chunk(b'ABCD', codecs.decode('DEADBEEF', 'hex_codec')))
self.assertEqual(io.tell(), 12)
示例15: test_decode_aes256_cbc_base64_decodes_a_blank_string
def test_decode_aes256_cbc_base64_decodes_a_blank_string(self):
self.assertEqual(Parser.decode_aes256_cbc_base64(
'', self.encryption_key),
b'')