博客
关于我
加密程序
阅读量: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/

    你可能感兴趣的文章
    POSIX thread编程中关于临界区内条件变量的分析
    查看>>
    POSIX与程序可移植性
    查看>>
    posix多线程有感--自旋锁
    查看>>
    SpringBoot中集成海康威视SDK实现布防报警数据上传/交通违章图片上传并在linux上部署(附示例代码资源)
    查看>>
    POSIX标准和XSI扩展
    查看>>
    post install error,please remove node_moules before retry
    查看>>
    postcss-pxtorem 参数之selectorBlackList、exclude的用法
    查看>>
    Postek博思得标签打印机更换电脑,打印出来标签空白
    查看>>
    postfix+ dovecot搭建邮件服务器
    查看>>
    postfix在邮件服务器中的使用
    查看>>
    PostGIS 3.1.2软件安装详细教程(地图工具篇.8)
    查看>>
    PostGIS中获取所有EPSG的编码以及对应Proj4字符串
    查看>>
    PostGIS在Windows上的下载与安装
    查看>>
    Qt开发——网络编程之UDP客户端
    查看>>
    postgis数据库优化_postgresql 性能优化
    查看>>
    postgis求面积、交集等相关函数
    查看>>
    postgis相关函数
    查看>>
    Postgres Docker版本安装mysql_fdw 插件
    查看>>
    Postgres invalid command \N数据恢复处理
    查看>>
    Postgres like 模糊查询匹配集合
    查看>>