【BLE】CC2541加密与解密实验

来源:互联网 发布:淘宝怎么可以买到弩 编辑:程序博客网 时间:2024/05/22 20:10

参考文献:AES加密算法简介

代码段:

 #include "ll.h" #include "hal_types.h" #include "demoEncryptAndDecrypt.h"/***********************************************     @ author:Tony     @ date: 2017/03/23     @ name:void TestDemoEncryptionAndDecryptionHandle(void)     @ description: Test 2541 encryption process and decryption process     @ parameter: NULL     @ return value : NULL     @ test state: okay***********************************************/void TestDemoEncryptionAndDecryptionHandle(void){    //密钥设置    uint8 ScretKeyVal[16] = {3,4,6,7,8,2,4,5,1,2,3,4,5,7,4,2};    //明文部分    uint8 TxPlainTextData[16] = {3,2,3,5,3,1,1,2,3,4,1,3,8,3,4,5};    //加密后的数据    uint8 SecretData[16] = {0};    //解密后数据    uint8 RxPlainTextData[16] = {0};        //加密处理    LL_Encrypt(ScretKeyVal, TxPlainTextData, SecretData);    //解密处理    LL_EXT_Decrypt(ScretKeyVal, SecretData, RxPlainTextData);}

解密后数据:

0 0