关于Data Matrix 基于ECC200标准的编码原理和相关开源代码 |
您所在的位置:网站首页 › 二维码生成代码格式怎么设置 › 关于Data Matrix 基于ECC200标准的编码原理和相关开源代码 |
文章目录
前言一、Data Matrix 的加密1.DM码的数据编码格式2.DM码原始数据编码方法3.DM码的大小和容量4.DM码填充字的生成方法5.校验码的生成方法6.DM码的布置
二、相关开源算法总结
前言
Data Matrix是一种二维码标签,可以用来储存信息,简称DM码。 本文记录学习Data Matrix的解码及加密,本文主要针对ECC200标准。 一、Data Matrix 的加密 1.DM码的数据编码格式|Data codewords|Stuffing codewords| Correction codewords| Data codewords: 从原始数据编码得到的数据字 Stuffing codewords:如果数据字区域没有填满,用来填充的字 Correction codewords: 基于数据字和填充字,用 Reed-Solomon算法来校验产生的校验字. 2.DM码原始数据编码方法
以下是DM码的大小和容量信息,可以看出数据区大小为8x8的DM码只能容纳3个byte的数据码和5个byte的校验码。 当数据字不足以填充所有的数据区域时,可以采用填充字。填充字的第一个字总是129,后面的字可以用以下公式获取。 o "%"代表求模,i代表第i个位置的数据 5.校验码的生成方法相关C代码如下 /* "prod(x,y,log,alog,gf)" returns the product "x" times "y" */ int prod(int x, int y, int *log, int *alog, int gf) { if (!x || !y) return 0; ELSE return alog[(log[x] + log[y]) % (gf-1)]; } /* "ReedSolomon(wd,nd,nc,gf.pp)" takes "nd" data codeword values in wd[] */ /* and adds on "nc" check codewords, all within GF(gf) where "gf" is a */ /* power of 2 and "pp" is the value of its prime modulus polynomial */ void ReedSolomon(int *wd, int nd, int nc, int gf, int pp) { int i, j, k. *log,*alog,*c; /* allocate, then generate the log & antilog arrays: */ log = malloc(sizeof(int) * gf); alog = malloc(sizeof(int) * gf); log[0] = 1-gf; alog[0] = 1; for (i = 1; i = gf) alog[i] ^= pp; log[alog[i]] = i; } /* allocate, then generate the generator polynomial coefficients: */ c = malloc(sizeof(int) * (nc+1)); for (i=1; i |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |