RC4加密解密

释放双眼,带上耳机,听听看~!

调用RC4函数时,会修改密钥。因此需要两组密钥,一组用来加密,一组用来解密。

#include
<openssl
/rc4
.h

  1. #include

<stdio
.h

  1. #include

<stdlib
.h

  1. #include

<
string
.h

  1. static unsigned char g_rc4key

[16
]

{

  1.       0x2c

, 0xb6
, 0xa1
, 0xe7
, 0xe1
, 0x0c
, 0x50
, 0x02
,

  1.         0xa5

, 0xde
, 0xae
, 0x7f
, 0xe6
, 0x05
, 0xbd
, 0x90
,

}
;

int main
(
)

{

  1.     unsigned char buffer

[10
]
;

  1.     unsigned char buffer1

[10
]
;

  1.     RC4_KEY m_rc4SendKey

, decryKey
;

  1.     char str

[10
]

"123456789"
;

  1.     

int
len
= 10
;

  1.     memset

(buffer
, 0
, 10
)
;

  1.     memset

(buffer1
, 0
, 10
)
;

  1.     RC4_set_key

(
&m_rc4SendKey
, sizeof
(g_rc4key
)
, g_rc4key
)
;

  1.     RC4_set_key

(
&decryKey
, sizeof
(g_rc4key
)
, g_rc4key
)
;

  1.     RC4

(
&m_rc4SendKey
,
len
, str
, buffer
)
;

  1.     printf

(
"org: %sn"
, str
)
;

  1.     RC4

(
&decryKey
,
len
, buffer
, buffer1
)
;

  1.     printf

(
"no_cry: %sn"
, buffer1
)
;

  1.     return 0

;

}

给TA打赏
共{{data.count}}人
人已打赏
安全技术安全运维

Windows服务器如何发现被黑

2018-5-20 12:24:31

安全技术

网站制作需要素材的实用网站

2021-12-21 16:36:11

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索