Hi, I''m writing an application that generate some sort of prepaid cards, each card with a PIN and a serial number. All serials and PINs are being hashed when saved to the database. For more security, I need the generated numbers to be sent via email to the Admin when they generated, there is no way for the admin to view the numbers from inside the application. The process is as the following: Admin chooses to generate 1000 new cards (for example) --> Numbers are sent to the Admin by email before they get hashed --> numbers are hashed and saved to the database. The above scenario works for me without problems, right now the generated numbers are being sent as plain text in the body of the email message, my question is that good for large amount of numbers (thousands of cards)? Or should I export them as a CSV file and send it as attachment? I checked FasterCSV and the standard Ruby CSV library but as I understand they wouldn''t work for huge amount of data. Should I consider exporting to Excel file? Or do you think that it''s just fine to send them in the body of the email message? Or do you suggest some alternative way that I didn''t think about? For reference: this is the generate method in the controller: def generate @cards = {} params[:card][:number_of_cards].to_i.times do pin = rand(999999999999).to_s.center(12, rand(9).to_s) serial = rand(999999999999).to_s.center(12, rand(9).to_s) @cards[serial] = pin Card.create({:pin => pin, :serial => serial}) end PostOffice.deliver_send_cards(@cards) redirect_to(cards_path) end In the model: def before_save self.pin = Card.encrypt(pin) self.serial = Card.encrypt(serial) end In the Action Mailder: def send_cards(cards) @recipients = "someemail-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" @from = "someaddress" headers "Reply-to" => "someemail-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" @subject = "New generated cards" @sent_on = Time.now body[:cards] = cards end send_cards.html.erb: <%@cards.each do |a,b| %> <%= a +","+ b %> <%end%> Thanks in advance --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Danimal
2008-Apr-13 14:00 UTC
Re: The best way to send generated numbers to an email address
I don''t see any problem with sending an email that''s multiple thousands of lines long. One thing you might consider, though: format the email so that it sends in a "textualized table"... i.e. instead of one number per line, have 4 or 5 with tab stops or even spacings, so it lays out like a table. Look at the Array function "in_groups_of" for grouping the cards array in chunks. Also, shouldn''t you slap some public/private key encryption on that? Sending card numbers in the clear via email is probably not a wise idea. You could encrypt the body of the email with your public key, then decrypt it on the admin''s email app with the admin''s private key. -Danimal On Apr 13, 4:47 am, "AN@S" <anas.marr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > I''m writing an application that generate some sort of prepaid cards, each > card with a PIN and a serial number. All serials and PINs are being hashed > when saved to the database. For more security, I need the generated numbers > to be sent via email to the Admin when they generated, there is no way for > the admin to view the numbers from inside the application. > The process is as the following: Admin chooses to generate 1000 new cards > (for example) --> Numbers are sent to the Admin by email before they get > hashed --> numbers are hashed and saved to the database. > > The above scenario works for me without problems, right now the generated > numbers are being sent as plain text in the body of the email message, my > question is that good for large amount of numbers (thousands of cards)? Or > should I export them as a CSV file and send it as attachment? I checked > FasterCSV and the standard Ruby CSV library but as I understand they > wouldn''t work for huge amount of data. Should I consider exporting to Excel > file? Or do you think that it''s just fine to send them in the body of the > email message? Or do you suggest some alternative way that I didn''t think > about? > > For reference: this is the generate method in the controller: > > def generate > @cards = {} > params[:card][:number_of_cards].to_i.times do > pin = rand(999999999999).to_s.center(12, rand(9).to_s) > serial = rand(999999999999).to_s.center(12, rand(9).to_s) > @cards[serial] = pin > Card.create({:pin => pin, :serial => serial}) > end > PostOffice.deliver_send_cards(@cards) > redirect_to(cards_path) > end > > In the model: > > def before_save > self.pin = Card.encrypt(pin) > self.serial = Card.encrypt(serial) > end > > In the Action Mailder: > > def send_cards(cards) > > @recipients = "someem...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" > @from = "someaddress" > headers "Reply-to" => "someem...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" > @subject = "New generated cards" > @sent_on = Time.now > > body[:cards] = cards > > end > > send_cards.html.erb: > > <%...@cards.each do |a,b| %> > <%= a +","+ b %> > <%end%> > > Thanks in advance--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Danimal, Thank you for your useful comments. About encryption with with my public key, can rails do this when sending the email? Regards On 13/04/2008, Danimal <fightonfightwell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > I don''t see any problem with sending an email that''s multiple > thousands of lines long. > > One thing you might consider, though: format the email so that it > sends in a "textualized table"... i.e. instead of one number per line, > have 4 or 5 with tab stops or even spacings, so it lays out like a > table. Look at the Array function "in_groups_of" for grouping the > cards array in chunks. > > Also, shouldn''t you slap some public/private key encryption on that? > Sending card numbers in the clear via email is probably not a wise > idea. You could encrypt the body of the email with your public key, > then decrypt it on the admin''s email app with the admin''s private key. > > -Danimal > > > On Apr 13, 4:47 am, "AN@S" <anas.marr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, > > I''m writing an application that generate some sort of prepaid cards, > each > > card with a PIN and a serial number. All serials and PINs are being > hashed > > when saved to the database. For more security, I need the generated > numbers > > to be sent via email to the Admin when they generated, there is no way > for > > the admin to view the numbers from inside the application. > > The process is as the following: Admin chooses to generate 1000 new > cards > > (for example) --> Numbers are sent to the Admin by email before they get > > hashed --> numbers are hashed and saved to the database. > > > > The above scenario works for me without problems, right now the > generated > > numbers are being sent as plain text in the body of the email message, > my > > question is that good for large amount of numbers (thousands of cards)? > Or > > should I export them as a CSV file and send it as attachment? I checked > > FasterCSV and the standard Ruby CSV library but as I understand they > > wouldn''t work for huge amount of data. Should I consider exporting to > Excel > > file? Or do you think that it''s just fine to send them in the body of > the > > email message? Or do you suggest some alternative way that I didn''t > think > > about? > > > > For reference: this is the generate method in the controller: > > > > def generate > > @cards = {} > > params[:card][:number_of_cards].to_i.times do > > pin = rand(999999999999).to_s.center(12, rand(9).to_s) > > serial = rand(999999999999).to_s.center(12, rand(9).to_s) > > @cards[serial] = pin > > Card.create({:pin => pin, :serial => serial}) > > end > > PostOffice.deliver_send_cards(@cards) > > redirect_to(cards_path) > > end > > > > In the model: > > > > def before_save > > self.pin = Card.encrypt(pin) > > self.serial = Card.encrypt(serial) > > end > > > > In the Action Mailder: > > > > def send_cards(cards) > > > > > @recipients = "someem...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" > > @from = "someaddress" > > headers "Reply-to" => "someem...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" > > > @subject = "New generated cards" > > @sent_on = Time.now > > > > body[:cards] = cards > > > > end > > > > send_cards.html.erb: > > > > <%...@cards.each do |a,b| %> > > <%= a +","+ b %> > > <%end%> > > > > Thanks in advance > > > >-- Anas Marrawi Visit me at: www.anasonline.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Danimal
2008-Apr-14 13:48 UTC
Re: The best way to send generated numbers to an email address
Sure! http://www.ahgsoftware.com/articles/2007/03/18/how-to-encrypt-ruby-on-rails-mail-with-gnupg http://agilewebdevelopment.com/plugins/gnupg -Danimal On Apr 14, 1:57 am, "AN@S" <anas.marr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Danimal, > Thank you for your useful comments. > About encryption with with my public key, can rails do this when sending the > email? > > Regards > > On 13/04/2008, Danimal <fightonfightw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > I don''t see any problem with sending an email that''s multiple > > thousands of lines long. > > > One thing you might consider, though: format the email so that it > > sends in a "textualized table"... i.e. instead of one number per line, > > have 4 or 5 with tab stops or even spacings, so it lays out like a > > table. Look at the Array function "in_groups_of" for grouping the > > cards array in chunks. > > > Also, shouldn''t you slap some public/private key encryption on that? > > Sending card numbers in the clear via email is probably not a wise > > idea. You could encrypt the body of the email with your public key, > > then decrypt it on the admin''s email app with the admin''s private key. > > > -Danimal > > > On Apr 13, 4:47 am, "AN@S" <anas.marr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > I''m writing an application that generate some sort of prepaid cards, > > each > > > card with a PIN and a serial number. All serials and PINs are being > > hashed > > > when saved to the database. For more security, I need the generated > > numbers > > > to be sent via email to the Admin when they generated, there is no way > > for > > > the admin to view the numbers from inside the application. > > > The process is as the following: Admin chooses to generate 1000 new > > cards > > > (for example) --> Numbers are sent to the Admin by email before they get > > > hashed --> numbers are hashed and saved to the database. > > > > The above scenario works for me without problems, right now the > > generated > > > numbers are being sent as plain text in the body of the email message, > > my > > > question is that good for large amount of numbers (thousands of cards)? > > Or > > > should I export them as a CSV file and send it as attachment? I checked > > > FasterCSV and the standard Ruby CSV library but as I understand they > > > wouldn''t work for huge amount of data. Should I consider exporting to > > Excel > > > file? Or do you think that it''s just fine to send them in the body of > > the > > > email message? Or do you suggest some alternative way that I didn''t > > think > > > about? > > > > For reference: this is the generate method in the controller: > > > > def generate > > > @cards = {} > > > params[:card][:number_of_cards].to_i.times do > > > pin = rand(999999999999).to_s.center(12, rand(9).to_s) > > > serial = rand(999999999999).to_s.center(12, rand(9).to_s) > > > @cards[serial] = pin > > > Card.create({:pin => pin, :serial => serial}) > > > end > > > PostOffice.deliver_send_cards(@cards) > > > redirect_to(cards_path) > > > end > > > > In the model: > > > > def before_save > > > self.pin = Card.encrypt(pin) > > > self.serial = Card.encrypt(serial) > > > end > > > > In the Action Mailder: > > > > def send_cards(cards) > > > > @recipients = "someem...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" > > > @from = "someaddress" > > > headers "Reply-to" => "someem...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" > > > > @subject = "New generated cards" > > > @sent_on = Time.now > > > > body[:cards] = cards > > > > end > > > > send_cards.html.erb: > > > > <%...@cards.each do |a,b| %> > > > <%= a +","+ b %> > > > <%end%> > > > > Thanks in advance > > -- > Anas Marrawi > Visit me at:www.anasonline.net--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---