コード例 #1
0
from pydmtx import DataMatrix
from PIL import Image

# Write a Data Matrix barcode
dm_write = DataMatrix()
dm_write.encode("Hello, world!")
dm_write.save("hello.png", "png")

# Read a Data Matrix barcode
dm_read = DataMatrix()
img = Image.open("hello.png")

print dm_read.decode(img.size[0], img.size[1], buffer(img.tostring()))
print dm_read.count()
print dm_read.message(1)
print dm_read.stats(1)
コード例 #2
0
ファイル: dm.py プロジェクト: krondor/RobotFightClubArena
 def writeDM(self):
     # Write a Data Matrix barcode
     dm_write = DataMatrix()
     dm_write.encode("Hello, world!")
     dm_write.save("hello.png", "png")
     return
コード例 #3
0
ファイル: encode.py プロジェクト: ghoff/cryptimage
digest.update(cryptimage.compress_key(ecpubkey))
fingerprint = digest.digest()

# NID_X9_62_prime256v1
ephemeral = EC.gen_params(EC.NID_X9_62_prime256v1)
ephemeral.gen_key()
ephpub=cryptimage.strip_asn1(ephemeral.pub().get_der())
ephpub=cryptimage.compress_key(ephpub)

shared = ephemeral.compute_dh_key(ecpub.pub())

#strip second half of key which is y cordinates and can be derived from first half
dk=cryptimage.KDF(shared[:len(shared)/2],128,fingerprint)

if debug: sys.stderr.write("dk = %s\n" % binascii.b2a_hex(dk))

account="2000111122223333"
amount="1500050"
pin="7654"

data=cryptimage.dataencode(account,amount,pin)
ct = cryptimage.encrypt_data(dk,data)

message = cryptimage.build_message(ephpub, ct)

dm_write = DataMatrix(scheme=DataMatrix.DmtxSchemeBase256)
dm_write.encode(message)
dm_write.save("dm.png", "png")

sys.exit(0)
コード例 #4
0
ファイル: example-dtmx.py プロジェクト: bashwork/common
import os
from pydmtx import DataMatrix
from PIL import Image

#------------------------------------------------------------
# write a data matrix barcode
#------------------------------------------------------------
path = os.path.abspath('.')
path = os.path.join(path, 'hello.png')

matrix = DataMatrix()
matrix.encode("Hello, world!")
matrix.save(path, "png")

#------------------------------------------------------------
# read a data matrix Barcode
#------------------------------------------------------------
matrix = DataMatrix()
image  = Image.open(path)

print matrix.decode(image.size[0], image.size[1], buffer(image.tostring()))
print matrix.count()
print matrix.message(1)
print matrix.stats(1)