当前位置:   article > 正文

C++简单数据加密算法实现加密和解密的代码_加密电子邮件c++代码

加密电子邮件c++代码

工作闲暇时间,把写内容过程中较好的内容珍藏起来,下面的资料是关于C++简单数据加密算法实现加密和解密的内容,应该是对小伙伴有用。

  This is a program for Encryption and Decryption
  This program uses the Simple Data Encryption Standard (SDES) Algorithm.
  This Algo takes 8-bits of plaintext at a time and produces 8-bits of ciphertext.
  It uses 10-bits of key for Encryption and Decryption.

  Developed by : Vivek Kumar (vivek_kumar_bt@yahoo.co.in)

   Created on : 31 March 2005
   Last Modified on : 10 April 2005

   Any sort of suggetions/comments are most welcome at vivek_kumar_bt@yahoo.co.in

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<assert.h>
void menuEn();
void menuDe();
int DoEnDe(int);

class SDES
{
private:
    char KEY[11],K1[9],K2[9],IPOutput[9],InvIPOutput[9];
    char F1Output[9],F2Output[9];
    char INPUT_BIT[9],OUTPUT_BIT[9];

public:
    unsigned char INPUT,OUTPUT;

    ~SDES();
    void GenerateKeys();
    void conv_to_bits(unsigned char );
    void DES_Encryption(unsigned char );
    void DES_Decryption(unsigned char );
    void SDES::GetChar();
};
{
    int i;
    {
        printf("nInValid Key-Length %s %d",key,strlen(key));
        getch();
        exit(1);
    }
    {
        KEY[i]=key[i];
    }
    KEY[10]='0';

}

void SDES::GenerateKeys()
{
    int i;

    for (i=0;i<10;i++)
        P10_OP[i]=KEY[P10[i]-1];

    P10_OP[10]='0';

    for (i=0;i<5;i++)
    {
        P10LEFT[i]=P10_OP[i];
        P10RIGHT[i]=P10_OP[i+5];
    }
    P10LEFT[5]='0';
    P10RIGHT[5]='0';

    pl=new char[6];
    pr=new char[6];

    pl=Left_Shift(P10LEFT,1);
    pr=Left_Shift(P10RIGHT,1);

    for (i=0;i<5;i++)
    {
        plpr[i]=pl[i];
        plpr[i+5]=pr[i];
    }
    plpr[10]='0';

    for (i=0;i<8;i++)
        K1[i]=plpr[P8[i]-1];


    pl1=Left_Shift(pl,2);
    pr1=Left_Shift(pr,2);

    for (i=0;i<5;i++)
    {
        plpr[i]=pl1[i];
        plpr[i+5]=pr1[i];
    }
    plpr[10]='0';

    for (i=0;i<8;i++)
    {
  • 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
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/990846
推荐阅读
相关标签
  

闽ICP备14008679号