TripleDes的IV的C#? [英] TripleDES IV for C#?

查看:119
本文介绍了TripleDes的IV的C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以当我说是这样的:

TripleDES tripledes = TripleDES.Create();
Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(password, plain);
tripledes.Key = pdb.GetBytes(16);
tripledes.IV = pdb.GetBytes(16);



我得到一个错误。所使用的错误是在关键的,但是它得到修复(我认为 - 除非你点的东西错了)。但是,当我设置IV发生错误:

I get an error. The error used to be on the key, but its been fixed (I think - unless you spot something wrong). However, the error occurs when I set the IV:

tripledes.IV = pdb.GetBytes(16);



它说,它不是一个有效的初始化向量。

It says that its not a valid initialization vector.

如何解决呢?

推荐答案

有关TripleDes的块大小为64位。你尝试设置128位

The block size for TripleDES is 64 bits. You are trying to set 128 bits.

这应该工作:

tripledes.IV = pdb.GetBytes(8);

这篇关于TripleDes的IV的C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆