博客
关于我
加密程序
阅读量: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 1258 Agri-Net
    查看>>
    poj 1286 Necklace of Beads
    查看>>
    POJ 1321 棋盘问题
    查看>>
    poj 1321(回溯)
    查看>>
    Qt读取注册表默认值
    查看>>
    poj 1679 判断MST是不是唯一的 (次小生成树)
    查看>>
    POJ 1703 Find them, Catch them
    查看>>
    POJ 1703 Find them, Catch them 并查集
    查看>>
    POJ 1738 An old Stone Game(石子合并)
    查看>>
    POJ 1740 A New Stone Game(博弈)题解
    查看>>
    Qt网络编程之实例二POST方式
    查看>>
    POJ 1765 November Rain
    查看>>
    poj 1860 Currency Exchange
    查看>>
    POJ 1961 Period
    查看>>
    POJ 2019 Cornfields (二维RMQ)
    查看>>
    poj 2057 The Lost House 贪心思想在动态规划上的应用
    查看>>
    poj 2057 树形DP,数学期望
    查看>>
    poj 2112 最优挤奶方案
    查看>>
    Qt编写自定义控件12-进度仪表盘
    查看>>
    poj 2186 Popular Cows :求能被有多少点是能被所有点到达的点 tarjan O(E)
    查看>>