XTEA加密/解密 [英] XTEA Encryption/Decryption

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

问题描述

我正在尝试解密使用XTEA加密的代码。我一直在使用这里找到的脚本,http://goo.gl/xCpgs,它在自己的加密/解密示例中工作。问题是它不会解密我的客户给我的代码。在代码示例描述中,它表示密钥。是16个字符,但我的客户端的密钥是32个字符,所以我认为这可能是问题的一部分,但我在代码中找不到如何使用32个字符键(如果这甚至是问题)。


以下是上面和下面链接中的类,它是加密和解密字符串的示例。如果有人可以提供帮助或更好的解决方案,我们非常感谢。我的猜测是它只允许我的32个char键中的16个。我尝试使用32个字符键,但代码似乎仍然只需要16个。帮助!


我也读过一些关于XTEA的东西,只能在相同的代码语言中使用地穴被制作了。任何人都可以验证这个吗?

I am trying to decrypt a code encrypted with XTEA. I have been using a script found here, http://goo.gl/xCpgs and it works within its own encrypt/decrypt example. The problem is that it will not decrypt a code given to me by my client. In the code examples description it says the "key" is 16 characters, but the key I have from my client is 32 characters so I think this may be part of the problem, but I cannot find out in the code how to make it work with a 32 char key (if that is even the issue).

Below is the class from the link above and below that are sample encrypt and decrypt strings. If anyone can provide help or a better solution, it is greatly appreciated. My guess is that it is only allowing 16 of my 32 char key. I tried to use a 32 char key, but the code still seemed to only want 16. Help!

I also read something about XTEA only working within the same code language each side of the crypt was made. Can anyone validate this?

展开 | 选择 | Wrap | 行号

推荐答案

XTEA使用128位密钥,或16个字节。如果你有一个来自客户端的32字节密钥,这可能意味着他们以十六进制格式给你。你需要将它从十六进制转换为十进制或ascii,无论你的函数接受什么。
XTEA uses a 128-bit key, or 16 bytes. If you have a 32 byte key from the client, that probably means they gave it to you in hex format. You''ll just need to convert it from hex to decimal or ascii, whichever your function accepts.


感谢@xyph的帮助。我想我差不多了。我可以将加密的字符串更改为base64,然后查看正确,但它仍然不会解密。我仍然可以解决28d75A09ec63cxvxve870fad25e79b8c的关键字符串问题吗?如何将其更改为16个字符?下面是我目前的代码。

Thanks to @xyph for the help. I think I''m almost there. I can get the encrypted string to change to base64 and it "looks" correct, but it still will not decrypt. Could I still be having an issue with the key string of "28d75A09ec63cxvxve870fad25e79b8c"? How do I change this into 16 characters? Below is my current code.

展开 | 选择 | Wrap | 行号


代码和说明中的密钥不同。这是为什么?哪一个是正确的?如果代码中的那个是给你的,那就是十六进制。请参阅我之前的帖子。
Your key in the code and in your description is different. Why is that? Which one is correct? If the one in the code is what was given to you, then that is hexadecimal. Refer back to my previous post.


这篇关于XTEA加密/解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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