数据转换-整数字节数组

任务详情

0. 在openEuler(推荐)或Ubuntu或Windows(不推荐)中完成下面任务

1 参考《GMT 0009-2012 SM2密码算法使用规范》第6节“数据转换” 在utils.h和utils.c中完成整数与8位字节串的转换功能(10'):
int Int2ByteArr(unsigned int i, unsigned char * ba);
int ByteArr2Int(unsigned char * ba,unsigned int * i);

2 并写出测试代码测试上述函数(不能与下面代码一样),比如(10'):
unsigned int i=123456789;
Int2ByteArr(i, ba);
//结果:ba  = {0x07,0x5B,0xCD,0x15};

unsigned char ba [] = {0x07,0x5B,0xCD,0x15};
ByteArr2Int(ba, &i);
//结果: i=123456789

3 提交代码(或代码链接)和运行结果

代码

https://gitee.com/chu-triumph/intbyte

截图

posted @ 2022-06-02 15:27  20191308_chuuuuer  阅读(18)  评论(0编辑  收藏  举报