APUE Learning Example Source Code
guowenxue
2020-03-07 f343af92f08c255ca8b996e59106814733b97a00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*********************************************************************************
 *      Copyright:  (C) 2018 LingYun IoT System Studio
 *                  All rights reserved.
 *
 *       Filename:  main.c
 *    Description:  This file is LingYun Crypto library test program
 *                 
 *        Version:  1.0.0(2018年12月20日)
 *         Author:  Guo Wenxue <guowenxue@gmail.com>
 *      ChangeLog:  1, Release initial version on "2018年12月20日 12时33分32秒"
 *                 
 ********************************************************************************/
 
#include <stdio.h>
#include <string.h>
#include "crypto.h"
 
int main(int argc, char *argv[])
{
    char            *message="abcdefghijklmnopq";
    char             ciphertext[64];
    char             plaintext[64];
 
    memset(ciphertext, 0, sizeof(ciphertext));
    if( encrypt(message, ciphertext, sizeof(ciphertext))< 0 )
    {
        printf("encrypt plaintext failure\n");
        return -1;
    }
    printf("encrypt ciphertext: %s\n", ciphertext);
 
 
    memset(plaintext, 0, sizeof(plaintext));
    if( decrypt(ciphertext, plaintext, sizeof(plaintext))< 0 )
    {
        printf("decrypt ciphertext failure\n");
        return -1;
    }
    printf("decrypt  plaintext: %s\n", plaintext);
 
    
    return 0;
}