MCPcopy Create free account
hub / github.com/Vicomtech/video-content-description-VCD / chainCodeBase64Encoder

Function chainCodeBase64Encoder

vcd/poly2d.py:284–300  ·  view source on GitHub ↗
(_chaincodevector, _chaincode_bits)

Source from the content-addressed store, hash-verified

282# Converts a vector of chaincode integers into a json printable characters string.
283# By joining the digits to compose a 6 bits integer and the converting that integer in base64 character.
284def chainCodeBase64Encoder(_chaincodevector, _chaincode_bits):
285 # Add odd number in the vector for codification
286 num_digits = int(6 / _chaincode_bits)
287 _outputstring = ""
288 rest = len(_chaincodevector) % num_digits
289 if rest != 0:
290 vectrest = int(num_digits - rest)
291 for i in range(0, vectrest):
292 _chaincodevector.append(0)
293 else:
294 vectrest = 0
295 for i in range(0, len(_chaincodevector), num_digits):
296 byte = 0
297 for j in range(0, num_digits):
298 byte += _chaincodevector[i + j] << (num_digits - 1 - j) * _chaincode_bits
299 _outputstring += base64Encoder(byte)
300 return _outputstring, vectrest
301
302
303# Converts back the json printable characters string to a vector of chaincode integers.

Callers

nothing calls this directly

Calls 1

base64EncoderFunction · 0.70

Tested by

no test coverage detected