开发者

Error correction using a key

I don't know a whole lot about today's encryption, signature, error correction, etc. technologies. Here is my situation:

Let's say I have a long document with chapters. I have one small chapter that is supposed to act as a key. The medium that I'll transfer this开发者_如何学运维 document is error-prone, but I'm confident that the key will pass through fine. After it is transfered, I would like to be able to use that key to correct possible errors that may have occurred during transmission.

Could you give an idea on what techniques are suitable for this?

Thank you.


I think you want an HMAC (Hashed Message Authentication Code) which produces a hashes from blocks of data, and uses a key. Initilialize the hash function with the key and successively process each chapter with the hash. A receiver with the key (which passes though correctly) will be able to check the validity of the HMAC. An invalid HMAC will indicate that there was a transmission error. Note that if the key is not the size of the hash block, then the key need to be padded or split into blocks (and padded if necessary).

Wikipedia has a good article with links to implementations in Python, Perl, Ruby, C, Java, and JavaScript

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜