在实现IDEA算法时,如何将输入英文文本解释为64位块? [英] How should I interpret an input English text as 64-bit blocks while implementing the IDEA algorithm?
本文介绍了在实现IDEA算法时,如何将输入英文文本解释为64位块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在实施IDEA)所以有一个问题:输入文本是如何解释的?(据我所知,IDEA使用XOR,乘法模式(2 ^ 16 + 1)和加法mod(2 ^ 16)操作。那么我应该如何将英文字母解释成位?)。任何帮助表示赞赏!
解决方案
如果文本是用ASCII编码写的,那么每个字符就会得到8位。也就是说,对于一个64位的块,你需要8个字符;您可能需要通过以下方式感受剩余空间\0。
对于其他编码,宽度通常为16位,然后每64位块占4个字符。
在计算机中,位是任何数据的基础。出于实际原因,使用 8位组,名称为 byte 。
A byte 是最小数据单位可用。绝对每件事都是由字节组成的。
所有你需要的是将任何内容转换为字节数组并用8字节的bloc提供加密例程,无论它们是什么。没有口译要做,英文字母与否。
Encrypted_data = IDEA_Encrypt(Original_Data,Key);
// Original_Data是包含任何内容的8个字节的块
// 密钥是加密密钥。
// Encrypted_data是8字节加密结果
Decrypted_data = IDEA_Decrypt(Encrypted_Data,Key);
// Decrypted_data等于Original_Data,无论如何。
I am implementing the IDEA) So there is a question: how is the input text interpreted?(as far as I am concerned the IDEA uses XOR,multiplication mod(2^16+1) and and addition mod(2^16) operations. So how should I interpret English letters into bits???). Any help is appreciated!
解决方案
If the text is written with ASCII encoding, you get 8bits per character. That is, you take 8 characters for one block of 64bits; you may need to feel up remaining space by e.g. \0.
For other encodings, the width is typically 16bits, then take 4 characters per 64bit block.
In computers, a bit is the base of any data. For practical reasons, a group of 8 bits is used, the name is byte.
A byte is the minimum unit of data available. Absolutely every thing is made of bytes.
All you need is to cast anything to a byte array and feed the encryption routine with blocs of 8 bytes, no matter what they are. There is no interpreting to do, English letters or not.
Encrypted_data = IDEA_Encrypt(Original_Data, Key); // Original_Data is a bloc of 8 bytes containing anything // Key is the encrypting key. // Encrypted_data is the 8 bytes encrypted result Decrypted_data = IDEA_Decrypt(Encrypted_Data, Key); // Decrypted_data is equal to Original_Data, no matter what.
这篇关于在实现IDEA算法时,如何将输入英文文本解释为64位块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文