· 7 years ago · Sep 09, 2018, 02:44 AM
1Rails: why is calling to_a on a string not valid in a rake task?
2require 'openssl'
3
4KEY = 'secretkey'
5
6 namespace :import do
7 task :users => :environment do
8 def decrypt_password(pw)
9
10 cipher = OpenSSL::Cipher::Cipher.new('bf-ecb')
11 cipher.decrypt
12 cipher.key = KEY.to_a.pack('H*') <<--------- FAILS RIGHT HERE on to_a
13
14 data = data.to_a.pack('H*')
15 data = cipher.update(data)
16 data << cipher.final
17 unpad(data)
18
19 end
20 end
21
22 ... other methods
23end
24
25"foo".chars.to_a
26
27["f","o","o"]
28
29"abcd".each_char.map {|c| c }