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

    你可能感兴趣的文章
    POJ 3083 Children of the Candy Corn 解题报告
    查看>>
    POJ 3253 Fence Repair C++ STL multiset 可解 (同51nod 1117 聪明的木匠)
    查看>>
    Qt笔记——控件总结
    查看>>
    poj 3262 Protecting the Flowers 贪心
    查看>>
    poj 3264(简单线段树)
    查看>>
    Qt笔记——布局管理三件套分割窗口、停靠窗口和堆栈窗口
    查看>>
    poj 3277 线段树
    查看>>
    POJ 3349 Snowflake Snow Snowflakes
    查看>>
    POJ 3411 DFS
    查看>>
    poj 3422 Kaka's Matrix Travels (费用流 + 拆点)
    查看>>
    Qt笔记——官方文档全局定义(二)Functions函数
    查看>>
    POJ 3468 A Simple Problem with Integers
    查看>>
    poj 3468 A Simple Problem with Integers 降维线段树
    查看>>
    poj 3468 A Simple Problem with Integers(线段树 插线问线)
    查看>>
    poj 3485 区间选点
    查看>>
    poj 3518 Prime Gap
    查看>>
    poj 3539 Elevator——同余类bfs
    查看>>
    Qt笔记——官方文档全局定义(三)Macros宏
    查看>>
    poj 3628 Bookshelf 2
    查看>>
    Qt笔记——官方文档全局定义(一)Types数据类型
    查看>>