在Ruby / Python中使用哪个AES库? [英] Which AES library to use in Ruby/Python?

查看:93
本文介绍了在Ruby / Python中使用哪个AES库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够在Ruby客户端和Python服务器之间发送加密数据(反之亦然),并且遇到了 ruby​​-aes gem / library。该库非常易于使用,但是我们一直难以在它和python的pyCrypto AES库之间传递数据。这些库是唯一使用的库,看起来不错,但它们似乎无法跨语言使用。有任何想法吗?

I need to be able to send encrypted data between a Ruby client and a Python server (and vice versa) and have been having trouble with the ruby-aes gem/library. The library is very easy to use but we've been having trouble passing data between it and the pyCrypto AES library for Python. These libraries seem to be fine when they're the only one being used, but they don't seem to play well across language boundaries. Any ideas?

编辑:我们正在通过SOAP进行通信,并且还尝试将二进制数据转换为base64无效。此外,更多的是两者之间的加密/解密几乎但不完全相同(例如,长度相差一个,或者解密后的字符串的末尾有多余的垃圾字符)

We're doing the communication over SOAP and have also tried converting the binary data to base64 to no avail. Also, it's more that the encryption/decryption is almost but not exactly the same between the two (e.g., the lengths differ by one or there is extra garbage characters on the end of the decrypted string)

推荐答案

结果是发生的事情是ruby-aes自动填充数据以填充16个字符,并在最终字符串的末尾添加一个空字符作为分隔符。 PyCrypto要求您执行16个字符的倍数,这样我们才能弄清ruby-aes在做什么。

Turns out what happened was that ruby-aes automatically pads data to fill up 16 chars and sticks a null character on the end of the final string as a delimiter. PyCrypto requires you to do multiples of 16 chars so that was how we figured out what ruby-aes was doing.

这篇关于在Ruby / Python中使用哪个AES库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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