# Decrypt this!

**URL:** <https://www.ruby-forum.com/t/decrypt-this/127708>\
**Category:** Ruby\
**Created:** [January 31, 2008, 4:46pm UTC](https://www.ruby-forum.com/t/decrypt-this/127708 "2008-01-31T16:46:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 31, 2008, 4:46pm UTC](https://www.ruby-forum.com/t/decrypt-this/127708/1 "2008-01-31T16:46:08Z")

</div>

Here is some code that adds encrypt/decrypt methods to string, quite  
handy.  
Problem is, I need to decrypt in .NET !!  
any idea how?

=============================

require ‘openssl’

$key = “A75435F0B240012A9489000C2952E41F”

class String

def encrypt(key=$key)  
e = OpenSSL::Cipher::Cipher.new ‘DES-EDE3-CBC’  
e.encrypt key  
s = e.update self  
s \<\< e.final  
s = s.unpack(‘H\*’)[0].upcase  
s  
end

def decrypt(key=$key)  
e = OpenSSL::Cipher::Cipher.new ‘DES-EDE3-CBC’  
e.decrypt key  
s = self.to\_a.pack(“H\*”).unpack(“C\*”).pack(“c\*”)  
s = e.update s  
s \<\< e.final  
s  
end

end

puts “hi there”.encrypt

irb(main):027:0\* puts “hi there”.encrypt  
A5C7BBF5CBDFE2EC0D5F3B55AC12B761

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 31, 2008, 4:50pm UTC](https://www.ruby-forum.com/t/decrypt-this/127708/2 "2008-01-31T16:50:54Z")

</div>

On Jan 31, 9:42 am, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Here is some code that adds encrypt/decrypt methods to string, quite  
> handy.  
> Problem is, I need to decrypt in .NET !!  
> any idea how?

Google?  
A .NET newsgroup/mailing list/forum?  
Use ruby2exe to create an executable and call that from .NET?  
Create a Ruby web service and call that from .NET?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 1, 2008, 7:00pm UTC](https://www.ruby-forum.com/t/decrypt-this/127708/3 "2008-02-01T19:00:03Z")

</div>

On Jan 31, 2008 9:49 AM, yermej [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

You have two options. Go to msdn, search for what you want (it’s in  
the standard .net libs), or use visual studio and let intelisense fill  
in everything for you, and _READ_ the popups that come up.

What of the (few) good things that can be said about .net is that it’s  
got almost everything in the world built in. What you’re describing  
should end up being about a 12-20 line [vb.net](http://vb.net) program, double that if  
you include comments, quadruple if try and do error handling (It’s an  
ugly language 😉

–Kyle

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 1, 2008, 7:01pm UTC](https://www.ruby-forum.com/t/decrypt-this/127708/4 "2008-02-01T19:01:14Z")

</div>

One of, not what of. Phew.
