better of all I been looking and Google for long before coming to ask
the stupid questions here but all I can find is examples with SHA1
and yes I know encrypt is not good but for the use and compatibility
with my mail I must use it.
Thanks and sorry for the noob questions.
<http://corelib.rubyonrails.org/classes/String.html#M001529>
class Users < ActiveRecord::Base
validates_presence_of :email, :crypt, :homedir, :maildir
attr_reader :crypt
def crypt=(pw)
@crypt = pw
salt = [Array.new(6){rand(256).chr}.join].pack("m").chomp # 2^48
combos
self.crypt = User.crypt.crypt(salt)
end
end
What I am doing wrong here? anyone have a howto to an example with
crypt() ?
ReK2 escribió:
hmm, the only reason I used attr_readed is because is the only way I
found to
"steal" the content of the form(that ROR created based on the info my my
database using scaffold :users )
I have not found a better way yet(but I am a noob so no surprise) is
there a better way to gain control of the form?
and this will respond your question below.
my intention is so the password field will write to my mysql database
with the unix encrypt since that is how postifx and the other non RoR
applications will read it.. if not I will have use SHA1 that seens like
it have lot of examples already.
like I mention in my other email, I told RoR about my mysql database, he
created a schema and that looks ok..
then with the scafford: I was very impresed how fast RoR will create
forms around my DB content.. that is good.. the down side is
that how do I gain back "posesion" of at least the crypt column content
so RoR will encrypted before it writes it to the DB..
that was my first question I found attr_reader so far. the other part is
to use a unix encrypt to do so. and found
.crypt(salt) so far googling around.
so so far I can't write to the DB encrypted thats my problem.
Thanks and hope people can chip in their two cents.
class Users < ActiveRecord::Base
validates_presence_of :email, :crypt, :homedir, :maildir
def crypt=(pw)
salt =
[Array.new(6){rand(256).chr}.join].pack("m").chomp # 2^48 combos
self[:crypt] = pw.crypt(salt)
end
end
This looks like it does the trick! thanks so much. even do I will like
if you can point me to a good doc about the problem I was having since I
really found things related but nothing really like I had, I don't just
want to copy and paste and play with it I will like to understand why I
had it wrong and why this works.
Thanks
ReK2 escribió: