Implicit declaration of function 'js_private_decrypt' is invalid in C99

KralLee 2014-07-29 07:18:12

Implicit declaration of function 'js_private_decrypt' is invalid in C99


就是这么一个问题...在64位下就会出现这个问题。不是64位就可以了。
解决方法也看了很多
1、修改target->C Language Dialect 这个方法不行。
2、是不是有什么c的库没有添加上,具体也不知道要添加什么库。
错误代码
char *plainText = js_private_decrypt([cipher UTF8String], [privateKeyPath UTF8String]);

当然,js_private_decrypt,这个方法也得贴出来。
char *js_private_decrypt(const char *cipher_text, const char *private_key_path) {
RSA *rsa_privateKey = NULL;
FILE *fp_privateKey;
int rsa_private_len;

if ((fp_privateKey = fopen(private_key_path, "r")) == NULL) {
printf("Could not open %s\n", private_key_path);
return '\0';
}

if ((rsa_privateKey = PEM_read_RSAPrivateKey(fp_privateKey, NULL, NULL, NULL)) == NULL) {
printf("Error loading RSA Private Key File.");
return '\0';
}
fclose(fp_privateKey);

printf("Cipher text: %s\n", cipher_text);

rsa_private_len = RSA_size(rsa_privateKey);
printf("RSA private length: %d\n", rsa_private_len);

size_t crypt_len = 0;

unsigned char *crypt = base64_decode(cipher_text, strlen(cipher_text), &crypt_len);

printf("Decoded cipher: %s\nCrypt length: %ld\n", crypt, crypt_len);

// If no static, it will cause "address of stack memory associated with local variable ...", which mean the variable will released from memory after the end of this function
char *plain_char = malloc(crypt_len);
// initialize
strcpy(plain_char, "");

char *err = NULL;
for (int i = 0; i < crypt_len; i += rsa_private_len) {
unsigned char *crypt_chunk = malloc(rsa_private_len + 1);
memcpy(&crypt_chunk[0], &crypt[i], rsa_private_len);

printf("Crypt chunk: %s\n", crypt_chunk);

unsigned char *result_chunk = malloc(crypt_len + 1);
int result_length = RSA_private_decrypt(rsa_private_len, crypt_chunk, result_chunk, rsa_privateKey, RSA_PKCS1_PADDING);
// chunk length should be the size of privatekey (in bytes) minus 11 (overhead during encryption)
printf("Result chunk: %s\nChunk length: %d\n", result_chunk, result_length);

// this is to omit the dummy character behind
// i.e. Result chunk: ABC-1234567-201308101427371250-abcdefghijklmnopqrstuv\240Z
// Chunk length: 53
// New chunk: ABC-1234567-201308101427371250-abcdefghijklmnopqrstuv
//
// by copying the chunk to a temporary variable with an extra length (i.e. in this case is 54)
// and then set the last character of temporary variable to NULL
char tmp_result[result_length + 1];
memcpy(tmp_result, result_chunk, result_length);
tmp_result[result_length] = '\0';
printf("New chunk: %s\n", tmp_result);

if (result_length == -1) {
ERR_load_CRYPTO_strings();
fprintf(stderr, "Error %s\n", ERR_error_string(ERR_get_error(), err));
fprintf(stderr, "Error %s\n", err);
}

strcat(plain_char, tmp_result);
}

RSA_free(rsa_privateKey);
printf("Final result: %s\n", plain_char);

return plain_char;
}


...全文
1696 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xj309508871 2014-11-07
  • 打赏
  • 举报
回复
已经解决这个问题了,报错原因是找不到这个函数,在文件中 引入 函数所在的头文件 即可 #import <objc/runtime.h>
xj309508871 2014-11-07
  • 打赏
  • 举报
回复
我也遇到了这个问题: 64位编译就报错,32位正常运行。 Implicit declaration of function 'class_getProperty' is invalid in C99.
if (class_getProperty([aViewController class], "block"))
    {
        // it has that property!
        [aViewController setBlock:block];
    }
KralLee 2014-07-30
  • 打赏
  • 举报
回复
引用 1 楼 zhangao0086 的回复:
你是不是在申明js_private_decrypt这个方法之前就使用了这个方法?
不会啊,声明和使用都不在一个类中的。 这个不应该是编码的问题,因为我的非64位都可以运行的。
Bannings 2014-07-29
  • 打赏
  • 举报
回复
你是不是在申明js_private_decrypt这个方法之前就使用了这个方法?
打开链接下载源码: https://pan.quark.cn/s/05da658a2377 在信息技术领域中,输入法作为操作系统的一个核心构成部分,赋予了用户利用键盘输入多语种文字的能力。"ime-日语输入法安装必须文件"这一资源是一套为日语输入法部署而设计、包含全部必要元素的集成包,对于那些需要在个人计算机上执行日语文字输入的操作者而言具有不可替代的作用。接下来将深入剖析其中所包含的核心概念。 IME(Input Method Editor,输入法编辑器)是操作系统内的一种软件支持服务,其功能在于为非拉丁字符环境提供文字输入方案,例如中文、日文、韩文等文字系统。在日本地区,IME通常被用来将罗马字(罗马拼音)形式的输入转换为平假名、片假名乃至汉字。此压缩文件内含的日语IME文件夹即为执行这一转换功能的关键要素。 kbdjpn.dll被视为一个关键的系统性文件,其意指“Japanese Keyboard Layout”(日语键盘布局)。该动态链接库文件负责设定日语键盘的排列方式及快捷操作组合,使用户能够借助常规的QWERTY键盘输入日语文字。倘若缺少这一文件,即便已经安装了日语输入法,依然无法正常显示及输入日语字符。 另外,imjp81k.dll同样是一个重要的系统性构成,它属于日语IME的范畴,全称为“Input Method Japanese for Windows 8.1 and later, Katakana mode”(适用于Windows 8.1及更新版本的日语输入法,片假名模式)。该文件支持日语的片假名输入,是处理日语输入的核心组成部分。在安装或升级日语输入法的过程中,保证imjp81k.dll的准确性与完整性显得尤为关键。 压缩包所含的"Window...
内容概要:本文研究了基于DPWMA调制与正负序分离的ANPC三电平并网逆变器前馈控制策略,旨在解决传统三电平逆变器在谐波抑制、电网不平衡适应性及动态响应方面的技术瓶颈。通过构建融合双极性倍频脉宽调制(DPWMA)、正负序分离锁相控制与电网电压前馈的一体化控制体系,全面优化逆变器的输出波形质量、相位同步精度与抗扰能力。文章深入分析了ANPC三电平拓扑的结构优势,如开关损耗均衡、中点电位可控性强和电压利用率高等特点,并设计了包含信号采集、核心控制与调制驱动三层架构的完整控制系统。通过Simulink仿真平台对稳态运行、电网不平衡及动态扰动等多种工况进行验证,结果表明该策略显著降低了总谐波畸变率,提升了锁相精度与系统动态稳定性,有效增强了逆变器在复杂电网环境下的适应能力和运行可靠性。; 适合人群:具备电力电子、自动控制及新能源并网相关基础知识,从事新能源发电、微电网、电力系统仿真等领域的科研人员与工程技术人员,特别适合研究生及以上层次的研究者。; 使用场景及目标:①用于提升大功率并网逆变器在电网电压不平衡、谐波干扰和动态扰动等复杂工况下的运行性能;②为高电能质量要求的应用场景提供先进控制解决方案;③支持科研仿真、论文复现与实际工程项目中的高性能并网控制系统设计与优化。; 阅读建议:建议结合提供的Simulink仿真模型进行实践操作,重点理解DPWMA调制机制、正负序分离锁相算法与电网电压前馈控制之间的协同作用,按照文档结构系统学习,并与传统控制策略进行对比分析,以深入掌握改进策略的技术优势与实现细节。

29,039

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧