APUE Learning Example Source Code
guowenxue
2020-04-13 808fdc2c3745074a941fc73c9e6233d8e41cfdc0
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*********************************************************************************
 *      Copyright:  (C) 2020 LingYun IoT System Studio
 *                  All rights reserved.
 *
 *       Filename:  encrypto.c
 *    Description:  This file 
 *                 
 *        Version:  1.0.0(2020年04月04日)
 *         Author:  Guo Wenxue <guowenxue@gmail.com>
 *      ChangeLog:  1, Release initial version on "2020年04月04日 21时02分36秒"
 *                 
 ********************************************************************************/
 
#include <stdio.h>
#include <string.h>
 
#include "encrypto.h"
 
int       g_var = 0;
 
static int test(void)
{
    return 0;
}
 
int encrypto(char *str, char *ciphertxt, int size) 
{
    int i;
 
    test();
 
    if(!str || !ciphertxt || size<strlen(str))
    {
        printf("%s:%d %s(): Invalid input arguments\n", __FILE__, __LINE__, __FUNCTION__);
        return -1;
    }
 
    for(i=0; i<strlen(str); i++)
    {
        ciphertxt[i]=str[i]+1;
    }
 
 
    g_var ++;
 
    return 0;
}
 
 
int decrypto(char *ciphertxt, char *text, int size)
{
    int i;
 
    if( !ciphertxt || !text || size<strlen(ciphertxt) )
    {
        printf("%s:%d %s(): Invalid input arguments\n", __FILE__, __LINE__, __FUNCTION__);
        return -1;
    }
 
    for(i=0; i<strlen(ciphertxt); i++)
    {
        text[i]=ciphertxt[i]-1;
    }
 
    return 0;
}