A
aktxyz
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
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