保护 Ruby 代码
我正在编写 Ruby 应用程序,我想使用一些绝密算法。那么如何最好地保护它们免受未经授权的访问呢?
我有 2 个想法:
- 用 C 编写并使用 FFI 加载(我想知道这种方式是否可行)
- 编组 ruby 代码,对其进行编码,然后存储在文件中
也许有人知道更好的想法,或者可以告诉我这些想法是愚蠢或错误的。谢谢指教。
I'm writing Ruby app and I want to use some top-secret algorithms. So how would be the best to protect them from unauthorized access.
I have 2 ideas:
- write them in C and load using FFI (I wonder if It's possible this way)
- Marshal ruby code, encode it and then store in file
Maybe someone know better idea or can show me that these ideas are stupid or wrong. Thanks in advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您无法通过将其更改为 C 来保护您正在编写的算法。也许您可以加密源文件。尝试 truecrypt
编辑
经过一番谷歌搜索后,我发现了这些与 ruby 代码混淆相关的文章
You cannot protect the algorithm you are writing by changing it to C .. May be you can encrypt the source files. Try truecrypt
Edit
After some googling i found these articles related to ruby code obfuscation
您可以尝试一些代码混淆技术。例如 RubyEncoder 将 Ruby 源代码编译为加密的字节码格式。这是与您的问题相关的另一个线程 Ruby obfuscator
You can try some code obfuscation techniques. For example RubyEncoder compiles Ruby source code into a encrypted bytecode format. And here is another thread related to your question Ruby obfuscator
如果您愿意制作自己的解决方案而不是购买,并且已经制作了像 RubyEncoder 这样的解决方案,如其他答案所述,有一篇文章试图描述方法来保护您的源代码,您还可以实现您认为可行的各种保护,因为您将手动完成所有操作:
http://mountcastle.posterous.com/protecting-your-ruby-source-code-for-end-user
If you are willing to craft your own solution instead of buying and already made one like RubyEncoder, as stated on other answer here, there is an article that try to describe a method to protect your source code, and you can also implement all sort of protection you think is feasible, as you are going to do all by hand:
http://mountcastle.posterous.com/protecting-your-ruby-source-code-for-end-user