char plainText[16] = {0};strcpy(plainText, "ThisThisThisTh");const char* userstrkey = "abcdefghabcdefgh";CCLog("plainText = %s", plainText);AES_KEY key;AES_set_encrypt_key((unsigned char *)userstrkey, 128, &key);unsigned char encryptText[80] = {0};for (int i = 0; i < strlen(plainText); i += 16) {AES_encrypt((const unsigned char *)(plainText + i), encryptText + i, &key);}CCLog("length = %d", strlen((const char *)encryptText));for (int i = 0; i < strlen((const char *)encryptText); i++) {printf(" %d ", encryptText[i]);}unsigned char origText[80] = {0};AES_set_decrypt_key((unsigned char *)userstrkey, 128, &key);for (int i = 0; i < strlen((const char*)encryptText); i += 16) {AES_decrypt(encryptText + i, origText + i, &key);}CCLog("OrigText = %s", origText);
OpenSSL AES使用
最新推荐文章于 2024-08-16 19:13:12 发布