⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qa.c

📁 加解密包
💻 C
字号:
/*      Time-stamp: <QA.c - Sun 8/17/2003 13:40:24 by tony>        Contact: Tony Song    revision : 1.3.0     This sample code works on Solaris 2.6 and above, Linux, Win32    Dependency: stringencrypt.h, lib_cstr_xxx.a        purpose:  Stress test the usage of the following functions:    int DJStrEncrypt(char *ClearText,char *EncryptedData);    int DJStrDecrypt(char *EncryptedData,char *ClearText);    int strEncrypt(char *passwd, char *ClearText,char *EncryptedData);    int strDecrypt(char *passwd, char *EncryptedData,char *ClearText); */#include <stdlib.h>#include <stdio.h>#include <string.h>#include "stringencrypt.h"void usage(void);/*******************  Perform encrypt operation *******************/int do_crypto (char *passwd, char *clearText) {  char EncryptedData[1024];  int ret;  /* User program should calcuate the length     of input clear text to avoid buffer overflow;     for demo purpose only, we use fixed length*/  ret = strEncrypt(passwd,clearText,EncryptedData);  if ( ret != 0 ) {/* failed */    printf("The string encrypt failed; Error #:[%d]!\n",ret);    return -1;  }    printf("** ->>> [ %s %s %s ] <<<- **\n",clearText, passwd, EncryptedData);/*******************  Perform decrypt operation *******************/  ret = strDecrypt(passwd,EncryptedData,clearText);  if ( ret != 0 ) {/* failed */    printf("The string decrypt failed! #%d\n",ret);    return -1;  }  printf("Decrypt result: %d -> %s\n\n",strlen(clearText),clearText);  return 0;}main(int argc, char *argv[]){  char ClearText[1024];  char passwd[]="this is a passphrse";  int i,ret;    if ( argc < 2 ) {    usage();    exit(0);  }  i=0;  for (;;) {    sprintf(ClearText,"%s_%d", argv[1],i++);    ret=do_crypto(passwd, ClearText);    if (ret != 0)      return ret;//    sleep(1);  }}void usage(void){  printf(" Usage:\n\n");  printf(" example string         ;encrypt/decrypt the clear string.\n");  return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -