2

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.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
dreake
  • 129
  • 2
  • 4
  • Don't distribute the source code? Or is that crazy? – zxt Mar 21 '11 at 12:19
  • 1
    Do you mean to protect it from your Web Hosting company? – Swanand Mar 21 '11 at 12:39
  • 2
    Top-secret code? Cool. I saw that movie. If you don't trust your customer and can't put in the legalese in your contract that will keep them in line, then don't sell the software to them. – the Tin Man Mar 21 '11 at 13:28
  • possible duplicate of [How to prevent my users to read my Ruby code ?](http://stackoverflow.com/questions/4385914/how-to-prevent-my-users-to-read-my-ruby-code) – Andrew Grimm Mar 21 '11 at 22:19
  • It'll be hosted solution but I want to protect it in case someone breaks in. Server would be in our company. – dreake Mar 24 '11 at 23:11

3 Answers3

6

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

  1. protecting-your-ruby-source-code-for-end-user-applications/
  2. Ruby Encoder Protects Source Code for US Department of Defense Project
  3. http://rubyencoder.com/
RameshVel
  • 64,778
  • 30
  • 169
  • 213
  • No offense, but this response is so general. What value does it offer? – Geo Mar 21 '11 at 12:10
  • 2
    Yeah, it was helpfull. Thanks to this response I found my solution (for now). http://ruby2cext.rubyforge.org/ – dreake Mar 24 '11 at 23:12
  • the first link is 404 now T^T old archive: http://web.archive.org/web/20110828153039/http://seanmountcastle.com/2007/12/protecting-your-ruby-source-code-for-end-user-applications/ – Kokizzu Sep 18 '13 at 02:05
0

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

Community
  • 1
  • 1
ZelluX
  • 69,107
  • 19
  • 71
  • 104
0

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

Gabriel Mazetto
  • 1,090
  • 1
  • 12
  • 23
  • 404 for now, old archive: http://web.archive.org/web/20130520100956/http://mountcastle.posterous.com/protecting-your-ruby-source-code-for-end-user – Kokizzu Sep 18 '13 at 02:03