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

    你可能感兴趣的文章
    Python IPL
    查看>>
    python join split
    查看>>
    python json文件传输图片
    查看>>
    python kivy AttributeError:‘super‘对象没有属性‘__getattr__‘
    查看>>
    Python Kivy ListView:如何删除选定的 ListItemButton?
    查看>>
    Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll
    查看>>
    Python Kivy库:跨平台应用开发
    查看>>
    python lambda表达式
    查看>>
    Python ldap3 代码从 SID 获取用户名
    查看>>
    Python list += iterable 的行为是否记录在任何地方?
    查看>>
    python list,str的拼接与转换
    查看>>
    python list函数使用总结_史上最全的Python数据结构:列表和元组用法总结
    查看>>
    python locust 性能测试:locust参数-保证并发测试数据唯一性,循环取数据
    查看>>
    python locust 性能测试:locust安装和一些参数介绍
    查看>>
    python log
    查看>>
    python logging basicconfig_python之logging.basicConfig
    查看>>
    Python logging模块使用
    查看>>
    python logging模块学习
    查看>>
    python mac地址_python中MAC地址打包问题
    查看>>
    python manage.py syncdb Unknown command: 'syncdb'问题解决方法
    查看>>