# Strange problem when using crypt

**URL:** <https://www.ruby-forum.com/t/strange-problem-when-using-crypt/110750>\
**Category:** Rails\
**Created:** [July 30, 2007, 5:10pm UTC](https://www.ruby-forum.com/t/strange-problem-when-using-crypt/110750 "2007-07-30T17:10:58Z")\
**Posts on this page:** 3\
**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:** [July 30, 2007, 5:10pm UTC](https://www.ruby-forum.com/t/strange-problem-when-using-crypt/110750/1 "2007-07-30T17:10:58Z")

</div>

Hi there,

I’m trying to utilise the crypt/rijndael algorithm in rails. I’ve  
written a small script separate from rails that takes a string and  
using a specified key encrypts it and saves it to a file.

I then would like to be able to copy the string in that file and paste  
it into my rails application source and decrypt it using the  
decrypt\_block method of rijndael.

The trouble is the string changes between the file and the pasted text  
in rails. I mean it looks that same but if I puts it out from rails it  
is different. I think this must be a character encoding problem but  
I’m not sure…

Does anyone have any ideas?

Thanks,  
Toby

---

<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:** [July 30, 2007, 5:46pm UTC](https://www.ruby-forum.com/t/strange-problem-when-using-crypt/110750/2 "2007-07-30T17:46:05Z")

</div>

What OS? What ar eyou using to open the file?

On Jul 30, 8:10 am, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<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:** [July 30, 2007, 5:50pm UTC](https://www.ruby-forum.com/t/strange-problem-when-using-crypt/110750/3 "2007-07-30T17:50:06Z")

</div>

Sorry should have been more explicit - I’m on OS X and I’m using  
TextMate.

After playing around I’ve found that if I save the file using MacRoman  
as the character encoding it works the way I expected.

Nonetheless I’d like to know a way of doing it even if the file is  
saved in UTF-8.

On Jul 30, 4:45 pm, “Christopher E. Franklin, Sr.”
