博客
关于我
加密程序
阅读量:199 次
发布时间:2019-02-28

本文共 1296 字,大约阅读时间需要 4 分钟。

加密程序是一种将信息转换为特定格式以确保安全的技术。以下是加密和解密的实现方法:

加密篇

  • 将要加密的内容保存到 text.in 文件中
  • 运行以下.cpp程序:
  • #include 
    #include
    #include
    #include
    #include
    using namespace std;#define mem(a, b) memset(a, b, sizeof(a))char ch[10000] = {0};int main() { FILE *Fp = fopen("text.in", "r"); FILE *fp = fopen("text.out", "w"); int len = 0; while (fscanf(Fp, "%c", &ch[len++]) != EOF) { ; } printf("长度(不超过10000):%d\n", len); ch[len] = 0; fprintf(fp, "%d\n", len); printf("\nstart:\n"); for (int i = 0; i < len; ++i) { printf("%c", ch[i]); } // 加密逻辑(以下为示例,实际应用中需根据需求调整) // 例如:将字符转换为ASCII码并进行数学变换 // 例如:ch[i] = (ch[i] - 'a' + 73) % 255;}

    运行完成后,加密后的数字会保存到 text.out 文件中。

    解密篇

  • 将加密后的数字保存到 text.out 文件中
  • 运行以下.cpp程序:
  • #include 
    #include
    #include
    #include
    #include
    using namespace std;#define mem(a, b) memset(a, b, sizeof(a))char ch[10000] = {0};int main() { FILE *fp = fopen("text.out", "r"); int len; fscanf(fp, "%d", &len); for (int i = 0; i < len; ++i) { // 解密逻辑(以下为示例,实际应用中需根据需求调整) // 例如:将字节转换为ASCII字符 // 例如:ch[i] = (ch[i] + 130) % 256; printf("%c", ch[i]); }}

    运行完成后,解密后的内容会在标准输出中显示。

    转载地址:http://esns.baihongyu.com/

    你可能感兴趣的文章
    php 返回html字符串长度限制,记一次js中和php中的字符串长度计算截取的终极问题和完美...
    查看>>
    php 阿里云oss 上传回调
    查看>>
    PHP 面向对象 final类与final方法
    查看>>
    php+JQ+EasyUI自动加载数据
    查看>>
    php+sql server根据自增序号id区间查询第几条到第几条的数据
    查看>>
    php--------获取当前时间、时间戳
    查看>>
    php--正则表达式
    查看>>
    php--防止sql注入的方法
    查看>>
    PHP-CGI Windows平台远程代码执行漏洞复现(CVE-2024-4577)
    查看>>
    php-cgi耗尽报502错误
    查看>>
    php-cgi(fpm-cgi) 进程 CPU 100% 与 file_get_content...
    查看>>
    PHP-DI/Invoker 开源项目使用教程
    查看>>
    php-fpm与Nginx运行常见错误说明
    查看>>
    php-fpm比php成为apache模块好在哪
    查看>>
    php-fpm超时时间设置request_terminate_timeout分析
    查看>>
    php-fpm进程数优化
    查看>>
    PHP-GD库-分类整理
    查看>>
    php-laravel框架用户验证(Auth)模块解析(一)
    查看>>
    php-laravel框架用户验证(Auth)模块解析(三)登录模块
    查看>>
    php-laravel框架用户验证(Auth)模块解析(二)注册模块
    查看>>