3des java ivparame_求高手看看des的加密问题
发布日期:2021-06-24 11:48:46 浏览次数:2 分类:技术文章

本文共 1075 字,大约阅读时间需要 3 分钟。

DES 标准确实只支持 64 位密钥。

如果你需要更高位的DES,可以使用3DES加密算法,这个算法可以支持128位和192位的密钥。

下面是例子

///

/// Encrypt by 3DES

///

/// input stream

/// output stream

/// Key, the size must be 16 or 24 and it must be a strong key!

/// IV, the size must be 8

/// the size of buffer

public static void EncryptBy3DES(Stream input, Stream output, byte[] key, byte[] iv, int bufSize)

{

CryptoStream cStream = new CryptoStream(output,

new TripleDESCryptoServiceProvider().CreateEncryptor(key, iv),

CryptoStreamMode.Write);

// Create a StreamWriter using the CryptoStream.

BinaryWriter sWriter = new BinaryWriter(cStream);

int readBytes = 0;

byte[] buf = new byte[bufSize];

// Read from input, write to crypto stream

while (true)

{

readBytes = input.Read(buf, 0, buf.Length);

if (readBytes == 0)

{

break;

}

sWriter.Write(buf, 0, readBytes);

}

cStream.FlushFinalBlock();

}

///

/// Encrypt by 3DES

///

/// input string

/// Key, the size must be 16 or 24 and it must be a strong key!

/// IV, the size must be 8

/// Encrypted string

public static string En

eaglet

|

园豆:17119

(专家六级)

|

2008-08-22 13:48

Ctrl+Enter键快速提交

转载地址:https://blog.csdn.net/weixin_32573931/article/details/114484300 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:autocad2014 连接mysql_auto mysql
下一篇:java统计插件_[Java教程]编写maven代码行统计插件

发表评论

最新留言

很好
[***.229.124.182]2024年04月09日 15时35分09秒