# Depcryption and base64

**URL:** <https://www.ruby-forum.com/t/depcryption-and-base64/121990>\
**Category:** Rails\
**Created:** [December 3, 2007, 6:11pm UTC](https://www.ruby-forum.com/t/depcryption-and-base64/121990 "2007-12-03T18:11:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [December 3, 2007, 6:11pm UTC](https://www.ruby-forum.com/t/depcryption-and-base64/121990/1 "2007-12-03T18:11:38Z")

</div>

Just wondering is anyone can explain this code to me:

Base64.encode64(@key.send("#{key\_type}\_encrypt", text))

I have this code the encrypts some information. This part seems to work  
fine. I using some software on the back end that I have written in VB to  
decrypt it and it seems to have issues. So I just wanted to make sure  
that the code i have written in Ruby does what I think it does, and that  
is that it encrypts the data and then encodes it to base 64? But I’m not  
sure if it does this for both the data and the keys? Thanks,

-S

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [December 3, 2007, 6:40pm UTC](https://www.ruby-forum.com/t/depcryption-and-base64/121990/2 "2007-12-03T18:40:07Z")

</div>

On 3 Dec 2007, at 17:11, Shandy N. wrote:

> that the code i have written in Ruby does what I think it does, and  
> that  
> is that it encrypts the data and then encodes it to base 64? But I’m  
> not  
> sure if it does this for both the data and the keys? Thanks,

Well it calls the method #{key\_type}\_encrypt on @key, with the  
parameter text.  
It then base64 encodes the result of that.

Fred
