用C语言来实现DES加密算法(很急)两天内

IDEA\u52a0\u5bc6\u7b97\u6cd5\u7684C\u8bed\u8a00\u5b9e\u73b0

1\u3001\u6570\u636e\u52a0\u5bc6\u7684\u57fa\u672c\u8fc7\u7a0b\u5c31\u662f\u5bf9\u539f\u6765\u4e3a\u660e\u6587\u7684\u6587\u4ef6\u6216\u6570\u636e\u6309\u67d0\u79cd\u7b97\u6cd5\u8fdb\u884c\u5904\u7406\uff0c\u4f7f\u5176\u6210\u4e3a\u4e0d\u53ef\u8bfb\u7684\u4e00\u6bb5\u4ee3\u7801\uff0c\u901a\u5e38\u79f0\u4e3a\u201c\u5bc6\u6587\u201d\uff0c\u4f7f\u5176\u53ea\u80fd\u5728\u8f93\u5165\u76f8\u5e94\u7684\u5bc6\u94a5\u4e4b\u540e\u624d\u80fd\u663e\u793a\u51fa\u672c\u6765\u5185\u5bb9\uff0c\u901a\u8fc7\u8fd9\u6837\u7684\u9014\u5f84\u6765\u8fbe\u5230\u4fdd\u62a4\u6570\u636e\u4e0d\u88ab\u975e\u6cd5\u4eba\u7a83\u53d6\u3001\u9605\u8bfb\u7684\u76ee\u7684\u3002
2\u3001\u5e38\u89c1\u52a0\u5bc6\u7b97\u6cd5DES\uff08Data Encryption Standard\uff09\uff1a\u6570\u636e\u52a0\u5bc6\u6807\u51c6\uff0c\u901f\u5ea6\u8f83\u5feb\uff0c\u9002\u7528\u4e8e\u52a0\u5bc6\u5927\u91cf\u6570\u636e\u7684\u573a\u5408\uff1b3DES\uff08Triple DES\uff09\uff1a\u662f\u57fa\u4e8eDES\uff0c\u5bf9\u4e00\u5757\u6570\u636e\u7528\u4e09\u4e2a\u4e0d\u540c\u7684\u5bc6\u94a5\u8fdb\u884c\u4e09\u6b21\u52a0\u5bc6\uff0c\u5f3a\u5ea6\u66f4\u9ad8\uff1bRC2\u548c RC4\uff1a\u7528\u53d8\u957f\u5bc6\u94a5\u5bf9\u5927\u91cf\u6570\u636e\u8fdb\u884c\u52a0\u5bc6\uff0c\u6bd4 DES \u5feb\uff1bIDEA\uff08International Data Encryption Algorithm\uff09\u56fd\u9645\u6570\u636e\u52a0\u5bc6\u7b97\u6cd5\uff1a\u4f7f\u7528 128 \u4f4d\u5bc6\u94a5\u63d0\u4f9b\u975e\u5e38\u5f3a\u7684\u5b89\u5168\u6027\uff1bRSA\uff1a\u7531 RSA \u516c\u53f8\u53d1\u660e\uff0c\u662f\u4e00\u4e2a\u652f\u6301\u53d8\u957f\u5bc6\u94a5\u7684\u516c\u5171\u5bc6\u94a5\u7b97\u6cd5\uff0c\u9700\u8981\u52a0\u5bc6\u7684\u6587\u4ef6\u5757\u7684\u957f\u5ea6\u4e5f\u662f\u53ef\u53d8\u7684\uff1bDSA\uff08Digital Signature Algorithm\uff09\uff1a\u6570\u5b57\u7b7e\u540d\u7b97\u6cd5\uff0c\u662f\u4e00\u79cd\u6807\u51c6\u7684 DSS\uff08\u6570\u5b57\u7b7e\u540d\u6807\u51c6\uff09\uff1bAES\uff08Advanced Encryption Standard\uff09\uff1a\u9ad8\u7ea7\u52a0\u5bc6\u6807\u51c6\uff0c\u662f\u4e0b\u4e00\u4ee3\u7684\u52a0\u5bc6\u7b97\u6cd5\u6807\u51c6\uff0c\u901f\u5ea6\u5feb\uff0c\u5b89\u5168\u7ea7\u522b\u9ad8\uff0c\u76ee\u524d AES \u6807\u51c6\u7684\u4e00\u4e2a\u5b9e\u73b0\u662f Rijndael \u7b97\u6cd5\uff1bBLOWFISH\uff0c\u5b83\u4f7f\u7528\u53d8\u957f\u7684\u5bc6\u94a5\uff0c\u957f\u5ea6\u53ef\u8fbe448\u4f4d\uff0c\u8fd0\u884c\u901f\u5ea6\u5f88\u5feb\uff1b\u5176\u5b83\u7b97\u6cd5\uff0c\u5982ElGamal\u3001Deffie-Hellman\u3001\u65b0\u578b\u692d\u5706\u66f2\u7ebf\u7b97\u6cd5ECC\u7b49\u3002\u6bd4\u5982\u8bf4\uff0cMD5\uff0c\u4f60\u5728\u4e00\u4e9b\u6bd4\u8f83\u6b63\u5f0f\u800c\u4e25\u683c\u7684\u7f51\u7ad9\u4e0b\u7684\u4e1c\u897f\u4e00\u822c\u90fd\u4f1a\u6709MD5\u503c\u7ed9\u51fa\uff0c\u5982\u5b89\u5168\u7126\u70b9\u7684\u8f6f\u4ef6\u5de5\u5177\uff0c\u6bcf\u4e2a\u90fd\u6709MD5\u3002
3\u3001\u4f8b\u7a0b\uff1a
#include#include#include#include#define maxim 65537#define fuyi 65536#define one 65536#define round 8unsigned int inv(unsigned int xin);unsigned int mul(unsigned int a,unsigned int b);void cip(unsigned int IN[4],unsigned int OUT[4],unsigned int Z[7][10]);void key(unsigned int uskey[9],unsigned int Z[7][10]);void de_key(unsigned int Z[7][10],unsigned int DK[7][10]);void main(){ int i,j,k,x; unsigned int Z[7][10],DK[7][10],XX[5],TT[5],YY[5]; unsigned int uskey[9];FILE *fpout,*fpin;printf("\n Input Key");for(i=1;i>16); if(p>7)&one; else if((i+1)%8==0)/* \u5bf9\u4e8eS[15],S[23],...\u8fdb\u884c\u8ba1\u7b97 */ S[i]=((S[i-15]>7)&one; else S[i]=((S[i-7]>7)&one; } /*\u53d6\u5f97\u5b50\u5bc6\u94a5*/ for(r=1;r<=round+1;r++) for(j=1;j<7;j++) Z[j][r]=S[6*(r-1)+j-1]; } /* \u8ba1\u7b97\u89e3\u5b50\u5bc6\u94a5DK */ void de_key(unsigned int Z[7][10],unsigned int DK[7][10]) { int j; for(j=1;j<=round+1;j++) {DK[1][round-j+2]=inv(Z[1][j]); DK[4][round-j+2]=inv(Z[4][j]); if(i==1|j==round+1) { DK[2][round-j+2]=(fuyi-Z[2][j])&one; DK[3][round-j+2]=(fuyi-Z[3][j])&one; } else { DK[2][round-j+2]=inv(Z[3][j]); DK[3][round-j+2]=inv(Z[2][j]); } } for(j=1;j<=round+1;j++) { DK[5][round-j+2]=inv(Z[5][j]); DK[6][round-j+2]=inv(Z[6][j]); } }

\u5fd8\u5dee\u4e0d\u591a\u4e86,\u5927\u6982\u5c31\u8fd9\u4e48\u505a\u7684,\u7b97\u6cd5\u81ea\u5b9a!


#include

#define N 8
void main()
{
int i,j,temp,count=0;
int number,num[N];
//\u8f93\u5165\u539f\u59cb\u6570\u636e
printf ("\u8bf7\u8f93\u5165\u4e00\u4e2a\u5c0f\u4e8e8\u4f4d\u7684\u6570:\n");
scanf ("%d",&number);
//\u6570\u636e\u5012\u5e8f
while (number>0)
{
num[count] = number % 10;
number = number / 10;
count++;
}
printf ("\n");
//\u6c42\u5f97\u6570\u5b57\u52a05\u518d\u9664\u4ee510\u6c42\u4f59\u6570\u5f97\u5230\u65b0\u6570\u636e
for (i=0;i<count;i++)
{
num[i] = (num[i]+5)%10;
}
printf ("\n");
//\u7b2c\u4e00\u4e2a\u548c\u6700\u540e\u4e00\u4e2a\u4e92\u6362\u4f4d\u7f6e
temp = num[0];
num[0] = num[count-1];
num[count-1] = temp;

DES虽然不难但是挺繁复的,代码如下,关键点都有英文解释,仔细看。各个函数的功能都可以从函数名看出来。

#include "pch.h"
#include "misc.h"
#include "des.h"

NAMESPACE_BEGIN(CryptoPP)

/* Tables defined in the Data Encryption Standard documents
* Three of these tables, the initial permutation, the final
* permutation and the expansion operator, are regular enough that
* for speed, we hard-code them. They're here for reference only.
* Also, the S and P boxes are used by a separate program, gensp.c,
* to build the combined SP box, Spbox[]. They're also here just
* for reference.
*/
#ifdef notdef
/* initial permutation IP */
static byte ip[] = {
58, 50, 42, 34, 26, 18, 10, 2,
60, 52, 44, 36, 28, 20, 12, 4,
62, 54, 46, 38, 30, 22, 14, 6,
64, 56, 48, 40, 32, 24, 16, 8,
57, 49, 41, 33, 25, 17, 9, 1,
59, 51, 43, 35, 27, 19, 11, 3,
61, 53, 45, 37, 29, 21, 13, 5,
63, 55, 47, 39, 31, 23, 15, 7
};

/* final permutation IP^-1 */
static byte fp[] = {
40, 8, 48, 16, 56, 24, 64, 32,
39, 7, 47, 15, 55, 23, 63, 31,
38, 6, 46, 14, 54, 22, 62, 30,
37, 5, 45, 13, 53, 21, 61, 29,
36, 4, 44, 12, 52, 20, 60, 28,
35, 3, 43, 11, 51, 19, 59, 27,
34, 2, 42, 10, 50, 18, 58, 26,
33, 1, 41, 9, 49, 17, 57, 25
};
/* expansion operation matrix */
static byte ei[] = {
32, 1, 2, 3, 4, 5,
4, 5, 6, 7, 8, 9,
8, 9, 10, 11, 12, 13,
12, 13, 14, 15, 16, 17,
16, 17, 18, 19, 20, 21,
20, 21, 22, 23, 24, 25,
24, 25, 26, 27, 28, 29,
28, 29, 30, 31, 32, 1
};
/* The (in)famous S-boxes */
static byte sbox[8][64] = {
/* S1 */
14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13,

/* S2 */
15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9,

/* S3 */
10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12,

/* S4 */
7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14,

/* S5 */
2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3,

/* S6 */
12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13,

/* S7 */
4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12,

/* S8 */
13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11
};

/* 32-bit permutation function P used on the output of the S-boxes */
static byte p32i[] = {
16, 7, 20, 21,
29, 12, 28, 17,
1, 15, 23, 26,
5, 18, 31, 10,
2, 8, 24, 14,
32, 27, 3, 9,
19, 13, 30, 6,
22, 11, 4, 25
};
#endif

/* permuted choice table (key) */
static const byte pc1[] = {
57, 49, 41, 33, 25, 17, 9,
1, 58, 50, 42, 34, 26, 18,
10, 2, 59, 51, 43, 35, 27,
19, 11, 3, 60, 52, 44, 36,

63, 55, 47, 39, 31, 23, 15,
7, 62, 54, 46, 38, 30, 22,
14, 6, 61, 53, 45, 37, 29,
21, 13, 5, 28, 20, 12, 4
};

/* number left rotations of pc1 */
static const byte totrot[] = {
1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28
};

/* permuted choice key (table) */
static const byte pc2[] = {
14, 17, 11, 24, 1, 5,
3, 28, 15, 6, 21, 10,
23, 19, 12, 4, 26, 8,
16, 7, 27, 20, 13, 2,
41, 52, 31, 37, 47, 55,
30, 40, 51, 45, 33, 48,
44, 49, 39, 56, 34, 53,
46, 42, 50, 36, 29, 32
};

/* End of DES-defined tables */

/* bit 0 is left-most in byte */
static const int bytebit[] = {
0200,0100,040,020,010,04,02,01
};

/* Set key (initialize key schedule array) */
DES::DES(const byte *key, CipherDir dir)
: k(32)
{
SecByteBlock buffer(56+56+8);
byte *const pc1m=buffer; /* place to modify pc1 into */
byte *const pcr=pc1m+56; /* place to rotate pc1 into */
byte *const ks=pcr+56;
register int i,j,l;
int m;

for (j=0; j<56; j++) { /* convert pc1 to bits of key */
l=pc1[j]-1; /* integer bit location */
m = l & 07; /* find bit */
pc1m[j]=(key[l>>3] & /* find which key byte l is in */
bytebit[m]) /* and which bit of that byte */
? 1 : 0; /* and store 1-bit result */
}
for (i=0; i<16; i++) { /* key chunk for each iteration */
memset(ks,0,8); /* Clear key schedule */
for (j=0; j<56; j++) /* rotate pc1 the right amount */
pcr[j] = pc1m[(l=j+totrot[i])<(j<28? 28 : 56) ? l: l-28];
/* rotate left and right halves independently */
for (j=0; j<48; j++){ /* select bits individually */
/* check bit that goes to ks[j] */
if (pcr[pc2[j]-1]){
/* mask it in if it's there */
l= j % 6;
ks[j/6] |= bytebit[l] >> 2;
}
}
/* Now convert to odd/even interleaved form for use in F */
k[2*i] = ((word32)ks[0] << 24)
| ((word32)ks[2] << 16)
| ((word32)ks[4] << 8)
| ((word32)ks[6]);
k[2*i+1] = ((word32)ks[1] << 24)
| ((word32)ks[3] << 16)
| ((word32)ks[5] << 8)
| ((word32)ks[7]);
}

if (dir==DECRYPTION) // reverse key schedule order
for (i=0; i<16; i+=2)
{
std::swap(k[i], k[32-2-i]);
std::swap(k[i+1], k[32-1-i]);
}
}
/* End of C code common to both versions */

/* C code only in portable version */

// Richard Outerbridge's initial permutation algorithm
/*
inline void IPERM(word32 &left, word32 &right)
{
word32 work;

work = ((left >> 4) ^ right) & 0x0f0f0f0f;
right ^= work;
left ^= work << 4;
work = ((left >> 16) ^ right) & 0xffff;
right ^= work;
left ^= work << 16;
work = ((right >> 2) ^ left) & 0x33333333;
left ^= work;
right ^= (work << 2);
work = ((right >> 8) ^ left) & 0xff00ff;
left ^= work;
right ^= (work << 8);
right = rotl(right, 1);
work = (left ^ right) & 0xaaaaaaaa;
left ^= work;
right ^= work;
left = rotl(left, 1);
}
inline void FPERM(word32 &left, word32 &right)
{
word32 work;

right = rotr(right, 1);
work = (left ^ right) & 0xaaaaaaaa;
left ^= work;
right ^= work;
left = rotr(left, 1);
work = ((left >> 8) ^ right) & 0xff00ff;
right ^= work;
left ^= work << 8;
work = ((left >> 2) ^ right) & 0x33333333;
right ^= work;
left ^= work << 2;
work = ((right >> 16) ^ left) & 0xffff;
left ^= work;
right ^= work << 16;
work = ((right >> 4) ^ left) & 0x0f0f0f0f;
left ^= work;
right ^= work << 4;
}
*/

// Wei Dai's modification to Richard Outerbridge's initial permutation
// algorithm, this one is faster if you have access to rotate instructions
// (like in MSVC)
inline void IPERM(word32 &left, word32 &right)
{
word32 work;

right = rotl(right, 4U);
work = (left ^ right) & 0xf0f0f0f0;
left ^= work;
right = rotr(right^work, 20U);
work = (left ^ right) & 0xffff0000;
left ^= work;
right = rotr(right^work, 18U);
work = (left ^ right) & 0x33333333;
left ^= work;
right = rotr(right^work, 6U);
work = (left ^ right) & 0x00ff00ff;
left ^= work;
right = rotl(right^work, 9U);
work = (left ^ right) & 0xaaaaaaaa;
left = rotl(left^work, 1U);
right ^= work;
}

inline void FPERM(word32 &left, word32 &right)
{
word32 work;

right = rotr(right, 1U);
work = (left ^ right) & 0xaaaaaaaa;
right ^= work;
left = rotr(left^work, 9U);
work = (left ^ right) & 0x00ff00ff;
right ^= work;
left = rotl(left^work, 6U);
work = (left ^ right) & 0x33333333;
right ^= work;
left = rotl(left^work, 18U);
work = (left ^ right) & 0xffff0000;
right ^= work;
left = rotl(left^work, 20U);
work = (left ^ right) & 0xf0f0f0f0;
right ^= work;
left = rotr(left^work, 4U);
}

// Encrypt or decrypt a block of data in ECB mode
void DES::ProcessBlock(const byte *inBlock, byte * outBlock) const
{
word32 l,r,work;

#ifdef IS_LITTLE_ENDIAN
l = byteReverse(*(word32 *)inBlock);
r = byteReverse(*(word32 *)(inBlock+4));
#else
l = *(word32 *)inBlock;
r = *(word32 *)(inBlock+4);
#endif

IPERM(l,r);

const word32 *kptr=k;

for (unsigned i=0; i<8; i++)
{
work = rotr(r, 4U) ^ kptr[4*i+0];
l ^= Spbox[6][(work) & 0x3f]
^ Spbox[4][(work >> 8) & 0x3f]
^ Spbox[2][(work >> 16) & 0x3f]
^ Spbox[0][(work >> 24) & 0x3f];
work = r ^ kptr[4*i+1];
l ^= Spbox[7][(work) & 0x3f]
^ Spbox[5][(work >> 8) & 0x3f]
^ Spbox[3][(work >> 16) & 0x3f]
^ Spbox[1][(work >> 24) & 0x3f];

work = rotr(l, 4U) ^ kptr[4*i+2];
r ^= Spbox[6][(work) & 0x3f]
^ Spbox[4][(work >> 8) & 0x3f]
^ Spbox[2][(work >> 16) & 0x3f]
^ Spbox[0][(work >> 24) & 0x3f];
work = l ^ kptr[4*i+3];
r ^= Spbox[7][(work) & 0x3f]
^ Spbox[5][(work >> 8) & 0x3f]
^ Spbox[3][(work >> 16) & 0x3f]
^ Spbox[1][(work >> 24) & 0x3f];
}

FPERM(l,r);

#ifdef IS_LITTLE_ENDIAN
*(word32 *)outBlock = byteReverse(r);
*(word32 *)(outBlock+4) = byteReverse(l);
#else
*(word32 *)outBlock = r;
*(word32 *)(outBlock+4) = l;
#endif
}

void DES_EDE_Encryption::ProcessBlock(byte *inoutBlock) const
{
e.ProcessBlock(inoutBlock);
d.ProcessBlock(inoutBlock);
e.ProcessBlock(inoutBlock);
}

void DES_EDE_Encryption::ProcessBlock(const byte *inBlock, byte *outBlock) const
{
e.ProcessBlock(inBlock, outBlock);
d.ProcessBlock(outBlock);
e.ProcessBlock(outBlock);
}

void DES_EDE_Decryption::ProcessBlock(byte *inoutBlock) const
{
d.ProcessBlock(inoutBlock);
e.ProcessBlock(inoutBlock);
d.ProcessBlock(inoutBlock);
}

void DES_EDE_Decryption::ProcessBlock(const byte *inBlock, byte *outBlock) const
{
d.ProcessBlock(inBlock, outBlock);
e.ProcessBlock(outBlock);
d.ProcessBlock(outBlock);
}

void TripleDES_Encryption::ProcessBlock(byte *inoutBlock) const
{
e1.ProcessBlock(inoutBlock);
d.ProcessBlock(inoutBlock);
e2.ProcessBlock(inoutBlock);
}

void TripleDES_Encryption::ProcessBlock(const byte *inBlock, byte *outBlock) const
{
e1.ProcessBlock(inBlock, outBlock);
d.ProcessBlock(outBlock);
e2.ProcessBlock(outBlock);
}

void TripleDES_Decryption::ProcessBlock(byte *inoutBlock) const
{
d1.ProcessBlock(inoutBlock);
e.ProcessBlock(inoutBlock);
d2.ProcessBlock(inoutBlock);
}

void TripleDES_Decryption::ProcessBlock(const byte *inBlock, byte *outBlock) const
{
d1.ProcessBlock(inBlock, outBlock);
e.ProcessBlock(outBlock);
d2.ProcessBlock(outBlock);
}

分也太少了,先做做

S盒用默认的吗???

分太少了,要不然就给你写了。。。

OPenSSL

  • des瑙e瘑绠楁硶,鍒╃敤C璇█瑙e瘑JAVA璇█鍔犲瘑鐨勫瘑鐮併傘傚瘑閽ヤ负12345678,鍔犲瘑...
    绛旓細// C 璇█ DES鐢ㄧ殑鏄 ECB妯″紡锛 娌℃湁濉厖 // 鍥犳Java绔瀵瑰簲锛 浣犵殑鏄庢枃鏄 liubiao 鍚楋紵// 鍙﹀ DES宸茬粡涓嶅畨鍏ㄤ簡锛 濡傛灉鍙互鏀逛负 3DES鎴栬 AES鍚с俻ublic class LearnDes { public static void main(String[] args) { try { System.out.println(encrypt("liubiao", "12345678"));System...
  • C璇█鑻辨枃鏂囨湰鍔犲瘑
    绛旓細fclose(fq);//鍏抽棴鍔犲瘑鍚庣殑鏂囦欢 remove("AAA12345678901.txt");//鍒犻櫎鍘熸枃浠 rename("tmp.txt","AAA12345678901.txt");//灏嗗姞瀵嗗悗鐨勬枃浠舵洿鎹负鍘熸枃浠跺悕 printf("\n");if(fp=fopen("AAA12345678901.txt","r")){ while((t=fgetc(fp))!=EOF)printf("%c",t);printf("\nEncryption success...
  • des绠楁硶鍔犲瘑瑙e瘑鐨瀹炵幇
    绛旓細2006-01-10 des鍔犲瘑瑙e瘑绠楁硶鐨勫畬鏁寸▼搴 2 2013-06-25 c# 鍋氫竴涓DES绠楁硶鍔犲瘑瑙e瘑鐨勭獥浣 1 2007-03-09 鐢╦ava瀹炵幇des鍔犲瘑鍜岃В瀵 8 2010-01-01 DES绠楁硶鍔犺В瀵嗘枃浠剁殑婧愪唬鐮,鏈濂芥湁鐣岄潰鐨勩 29 2008-02-29 DES鍔犲瘑绠楁硶C璇█瀹炵幇 30 2012-04-19 DES鍔犲瘑绠楁硶鐨勬祴璇曟暟鎹ず渚 5 鏇村绫讳技闂 > 涓...
  • 姹鐢–璇█鍐欏瘑鐮佸涓殑S鐩
    绛旓細缁欎綘涓des绠楁硶鐨剆鐩掑畾涔 const static char S_Box[8][4][16] = { // S1 14, 4,13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,4, 1, 14, 8, 13, 6, ...
  • 濡備綍鍦↙inux涓鐢–璇█瀹炵幇MD5/DES瑙e瘑
    绛旓細鐩稿叧搴撳嚱鏁板涓嬶細include <openssl/md5.h> unsigned char *MD5(const unsigned char *d, unsigned long n,unsigned char *md);int MD5_Init(MD5_CTX *c);int MD5_Update(MD5_CTX *c, const void *data,unsigned long len);int MD5_Final(unsigned char *md, MD5_CTX *c);...
  • ...鍙互鐢ㄤ簬瑙e瘑鐢–璇█鍐鐨凞ES鍔犲瘑绠楁硶!鍏朵腑C璇█浠g爜瑙侀棶棰樿ˉ鍏卂鐧 ...
    绛旓細鍔犲瘑绠楁硶鍙互鍔犺В瀵嗘湁涓変釜鏉′欢锛屼竴涓槸闅忔満婧愶紝涓涓槸鍔犲瘑绠楁硶锛aes,des, java鍜宑++閮芥湁瀹炵幇锛岃繖涓綘涓嶇敤绠★級锛屼笁鏄~鍏呮柟娉曪紝淇濊瘉杩3涓潯浠朵竴鑷村氨鍙互鎴愬姛鍔犺В瀵
  • C#瀹炵幇DES鍔犲瘑鏃舵棤娉曞彇鍒板畬鏁寸殑64bit鏄庢枃鍧
    绛旓細杩欎簺鍏蜂綋鐨勮姹傝鐪嬪叿浣撶殑鍔犲瘑鏂瑰紡锛堟ā寮忥級銆備絾鐢变簬DES瀵硅薄浼氭鏌ワ紝鎵浠ュ湪C#涓棤璁烘槸鍚︿娇鐢ㄩ兘妫鏌V鐨勫笺DESCryptoServiceProvider鍙槸CSP瀹瑰櫒瀹炵幇DES鑰屽凡銆備娇鐢ㄥ畬鍏ㄤ竴鏍风殑Key鍜孖V锛岀浉鍚岀殑鍔犲瘑绠楁硶涓庡~鍏呮ā寮忥紝瀵圭浉鍚岀殑瀵嗘枃鍔犲瘑锛岀粨鏋滄槸涓鏍风殑鍚楋紵涓嶄竴鏍凤紒鍔犲瘑绠楁硶浜嗕负瀵规姉鍙嶅悜宸ョ▼锛屼娇鐢ㄥ悓涓绫诲璞″姞瀵嗙浉鍚...
  • IDEA鍔犲瘑绠楁硶鐨C璇█瀹炵幇
    绛旓細1銆鏁版嵁鍔犲瘑鐨勫熀鏈繃绋嬪氨鏄鍘熸潵涓烘槑鏂囩殑鏂囦欢鎴栨暟鎹寜鏌愮绠楁硶杩涜澶勭悊锛屼娇鍏舵垚涓轰笉鍙鐨勪竴娈典唬鐮侊紝閫氬父绉颁负鈥滃瘑鏂団濓紝浣垮叾鍙兘鍦ㄨ緭鍏ョ浉搴旂殑瀵嗛挜涔嬪悗鎵嶈兘鏄剧ず鍑烘湰鏉ュ唴瀹癸紝閫氳繃杩欐牱鐨勯斿緞鏉ヨ揪鍒颁繚鎶ゆ暟鎹笉琚潪娉曚汉绐冨彇銆侀槄璇荤殑鐩殑銆2銆佸父瑙鍔犲瘑绠楁硶DES锛Data Encryption Standard锛夛細鏁版嵁鍔犲瘑鏍囧噯锛岄熷害杈冨揩...
  • C璇█(鎴朇++)鎺у埗鍙扮▼搴瀹炵幇鏂囨湰杞崲鍔犲瘑
    绛旓細鏂囦欢閲囩敤DES绠楁硶瑙e瘑鏂囦欢 param file 宸鍔犲瘑鐨勬枃浠 濡c:/鍔犲瘑鍚庢枃浠.txt param destFile 瑙e瘑鍚庡瓨鏀剧殑鏂囦欢鍚 濡俢:/ test/瑙e瘑鍚庢枃浠.txt / private static void decrypt(String file, String dest, String pw) throws Exception { Cipher cipher = Cipher.getInstance("DES");cipher.init(Cipher....
  • 璋佹湁DES鍔犲瘑绠楁硶鐨勭▼搴 璋㈣阿(寰堟)
    绛旓細鑷繁缁冩妧鏈殑璇濆啓鍐欐簮浠g爜鎸哄ソ鐨勶紝瑕佹槸寮鍙戜笢瑗匡紝鏈濂鐢╟ryptopp杩欎釜搴擄紝鍔熻兘鍏ㄤ竴浜涳紝涔熸湁姣旇緝瀹屾暣鐨勭粍缁囦綋绯汇備笅闈㈢殑鏄垜鍐欑殑锛岀敤浜哻ryptopp杩欎釜搴擄紝闇瑕佷釜搴撴枃浠讹紝浣犺鐨勮瘽鐧惧害鐣欒█鎴戠粰浣犮傚姞涓婇偅涓猚ryptopp.lib灏辫兘杩愯锛屽彲鎯滄槸c++鐨勩傚彟澶栨垜杩欓噷鏈夎繖涓簱鐢ㄦ潵瀹炵幇DES鐨勭粏鑺備笂鐨绠楁硶鍙婃簮浠g爜锛屼絾涓...
  • 扩展阅读:扫一扫出答案 ... aes des加密区别 ... 10种常用的加密算法 ... c语言对字母简单加密 ... des加密的详细步骤 ... 画出des解密算法的流程图 ... des加密过程图 ... 公钥加密算法des ... des密钥有效个数 ...

    本站交流只代表网友个人观点,与本站立场无关
    欢迎反馈与建议,请联系电邮
    2024© 车视网