基本信息
源码名称:DES加解密示例
源码大小:8.22KB
文件格式:.zip
开发语言:C/C++
更新时间:2021-05-02
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
【文件目录】
DES-master
├── Riv85.txt
├── des.c
├── des.h
├── main.c
└── tables.h
0 directories, 5 files
【核心源码】
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "des.h" static const char *opt_string = "dc:k:h"; void display_usage() { // display usage... } int main(int argc, char *argv[]) { /* validate_des(); */ /* return 0; */ char mode = 'e'; uint64_t input = 0x0000000000000000; uint64_t key = 0x0000000000000000; char *input_str = NULL; char *input_key = NULL; int opt; while ((opt = getopt(argc, argv, opt_string)) != -1) { switch(opt) { case 'd': mode = 'd'; break; case 'h': display_usage(); return 0; case 'c': input_str = optarg; break; case 'k': input_key = optarg; break; default: return 0; } } if (!input_str || !input_key) { return 0; } if (strlen(input_str) != 16 || strlen(input_key) != 16) { return 0; } input = strtoul(input_str, NULL, 16); key = strtoul(input_key, NULL, 16); printf("%016llX\n", des(input, key, mode)); return 0; }