Displaying 20 results from an estimated 98 matches for "hexdigest".
2007 Nov 17
18
Syntax Problem
...is my code add on before the logged_in?:
def create
# if no password use old md5 and fill in with sha2
user = User.find_by_login(params[:login])
if #{user.crypted_password} == nil
#check_md5?
(params[:password],#{user.old_salt},#{user.hashed_password})
@p = Digest::MD5::hexdigest("#{params[:password]}")
@s = Digest::MD5::hexdigest(user.old_salt)
@pw = Digest::MD5.hexdigest(@s+@p)
if @pw == #{user.hashed_password}
flash.now[:notice] = "Passed"
# need to write pw
#user.crypted_password = self.encrypt("#{@p...
2006 Jul 19
6
ActiveRecord::RecordNotSaved - bizarre behaviour.
...SQL (0.000466) COMMIT
ActiveRecord::RecordNotSaved (ActiveRecord::RecordNotSaved):
...
As you can see, there''s no INSERT SQL generated, which is the root cause
of the problem.
In my user model, I have the following call back:
def before_create
self.password = Digest::SHA1.hexdigest(self.password)
self.rsskey = Digest::SHA1.hexdigest(Time.now.to_s+"_"+String.rand(15))
self.otp = Digest::SHA1.hexdigest(Time.now.to_s+"_"+String.rand(15))
self.verified = false
#logger.debug("--> "+self.to_s) #This is the magic line!!
end
T...
2006 Aug 07
2
NoMethod Error: Modifying Location of support modules
...rying to follow along with the Agile Development with Ruby on Rails
book and have encountered a problem with code having the following
syntax (partial class provided):
require "digest/sha1"
class User < ActiveRecord::Base
private
def self.hash_password(password)
Digest:SHA1.hexdigest(password)
end
end
I''m getting an error as:
undefined method `hexdigest'' for :SHA1:Symbol
I have installed Ruby 1.8.4. How can I correct this error? I''m running
on Mac OS X and have followed the build instructions for Macs to install
this version of Ruby. If I n...
2012 Jun 08
2
rubycas-server login fail
...n rubycas-server. It fails when try to hash password:
(/opt/puppet/share/rubycas-server/lib/casserver/authenticators/sql_encrypted.rb)
> def validate(credentials)
>
....
> encrypt_function = @options[:encrypt_function] ||
> ''user.encrypted_password ==
> Digest::SHA256.hexdigest("#{user.encryption_salt}::#{@password}")''
> ...
> return eval(encrypt_function) # FAIL
But in simple ruby script function *Digest::SHA256.hexdigest* works fine. I
changed to *OpenSSL::Digest::SHA256.hexdigest* in rubycas-server and it
works...
Maybe you can advice...
2009 Apr 21
11
can we decrypt the cipher encrypted using Digest::SHA1.hexdigest
what i have done is as follows
password = Digest::SHA1.hexdigest("#{salt}:#{password}")
pass1 = Digest::SHA1.hexdigest("#{salt}:asdfgh")
pass2 = Digest::SHA1.hexdigest("#{salt}:asdfgh")
pass3 = Digest::SHA1.hexdigest("#{salt}:qwerty")
puts pass1==pass2
puts pass1==pass3
This works fine
but i need to get the decrypted pa...
2010 May 10
6
de-crypting Ruby password with php.
...pp (was recently
upgraded from 1.6) and I need to integrate a php site to use the same
user login creds.
I''m not very versed with Ruby but I think this is the code that
encrypts the password.
[code]
# Encrypts some data with the salt.
def self.encrypt(password, salt)
Digest::SHA1.hexdigest("--#{salt}--#{password}--")
end
# Encrypts the password with the user salt
def encrypt(password)
self.class.encrypt(password, salt)
end[/code]
So.... I have full db access so I have the encrypted passwords and
their associated salts. And I need a php script to verify users....
2009 Sep 12
3
Cannot get my password to validate
...led in")
end
end
In my user controller, i have a digest to mask the password in the
database at registration:
def register
@title = "Register"
if request.post? and params[:user]
@user = User.new(params[:user])
@user.password = Digest::SHA1.hexdigest
(@user.password)
if @user.save
session[:user_id] = @user.id
flash[:notice] = "User ''#{@user.screen_name}'' created!"
redirect_to :action => "index", :controller => "user"
else @user.password...
2008 Dec 13
2
Need Help in converting php encryption decryption code to ruby on rails
...block;
$iv = substr( $block . $iv, 0, 512 ) ^ $password;
$i += 16;
}
while(i<n) do
pp_text=plain_text[i,16]
pp=''''
for j in 0..pp_text.size-1
pp+=pp_text.to_s(2)
end
block=pp^pack(''H*'',Digest::MD5.hexdigest(iv))
enc_text +=block
intermedi=block+iv
kk=''''
for j in 0..intermedi.size-1
kk +=intermedi[j].to_s(2)
end
iv=kk.to_i^pass.to_i
i +=16
end
return Base64.encode64(enc_text)
end
#
def md5_decrypt(enc_text,password,iv_len=16)
enc_text=Base64.decod...
2006 Feb 15
8
Agile book - getting confusing error
...udes...
require "digest/sha1"
class User < ActiveRecord::Base
attr_accessor :password
attr_accessible :login, :password, :name
def before_create
self.hashed_password = User.hash_password(self.password)
end
private
def self.hash_password(password)
Digest::SHA1.hexdigest(password)
end
end
Where am I going wrong?
Craig
2006 Jan 23
3
Encrypt/ Decrypt password
Hi,
I have user add/edit forms.While creating a user I tried the following
method to encrypt password and stored the encrypted password in the
table.
def self.sha1(pass)
Digest::SHA1.hexdigest("#{salt}--#{pass}--")
end
But when I try to edit the page I get the encrypted password in the
password field instead of the decrypted password. Is there any method
to decrypt the stored password.
Thanks.
Sainaba.
--
Posted via http://www.ruby-forum.com/.
2006 Apr 21
1
Catch authentication result from a model in a controller
...-------------------------
require ''digest/sha2''
class User < ActiveRecord::Base
validates_uniqueness_of :username
def password=(pass)
salt = [Array.new(6){rand(256).chr}.join].pack("m").chomp
self.password_salt, self.password_hash = salt,
Digest::SHA256.hexdigest(pass + salt)
end
def self.authenticate(username, password)
user = User.find(:first,
:conditions => [''username = ?'', username])
if user.blank? ||
Digest::SHA256.hexdigest(password + user.password_salt) !=
user.password_hash
raise...
2006 Aug 07
2
Bind variables error
...for 2) in: first_name = ? AND last_name = ?
I''m not sure why I"m getting this error ?
def self.authenticate(first_name, last_name, password)
user = User.find(:first, :conditions => [''first_name = ? AND
last_name = ?''])
if user.blank?
Digest::SHA256.hexdigest(password + user.password_salt) !=
user.password_hash
raise "Username or password invalid"
end
user
end
end
should it be user = User.find(:first, :second, :conditions ................
Or would it be something else ?
Stuart
2006 Jul 27
2
Creating multiple objects from form data
I''m in the process of creating a sign up form for an online application.
The form collects account info, company info, and then info for an
administrative user.
The method looks like this:
def create
@account = Account.create!(params[:account])
@company = @account.companies.create!(params[:company])
@user = @company.users.create!(params[:user])
end
However, this inevitably fails
2006 Aug 07
3
wrong number of bind variables
...se
logic to the model.
wrong number of bind variables (0 for 2) in: first_name = ? AND last_name = ?
def self.authenticate(first_name, last_name, password)
user = User.find(:first, :conditions => [''first_name = ? AND
last_name = ?''])
if user.blank?
Digest::SHA256.hexdigest(password + user.password_salt) !=
user.password_hash
raise "Username or password invalid"
end
user
end
end
I''m basically copying this out of Rails Recipes so not sure where the error is.
Stuart
2016 Feb 03
2
Python hashlib and ripemd160
Hi - I think the patent monster has struck again.
rmd = hashlib.new('ripemd160',binascii.unhexlify(someString)).hexdigest()
That fails - ValueError: unsupported hash type
From some googling, it appears that the supported hash types are from
OpenSSL and that means the OpenSSL in CentOS doesn't support ripemd160.
I've worked around other stuff missing from CentOS OpenSSL by building
LibreSSL and linking ag...
2006 Nov 16
1
Assigning to results - missing something
...sults[:file_hash]. Actually my initial pass at this was just to do a
s/@file_stats/results[:file_hash]/. Which gets me the following:
results[:file_stats] = {}
logger.debug " Generating checksum for #{path}..."
results[:file_stats][path][:checksum] =
Digest::MD5.hexdigest(File.read(path))
logger.debug " ...done"
logger.debug " Getting file size for #{path}..."
results[:file_stats][path][:size] = File.size(path)
logger.debug results[:file_stats][path][:size]
So as soon as I attempt the checksum assignment abov...
2006 Aug 07
8
Login form question
I''m using Rails Recipes to create a login form but instead of username
and password, my setup is firstname, lastname, password.
I seemed to be gramatically challenged and not sure how to set up the
parameter list. Can anyone offer up a suggestion.
The book shows the method starting like:
if request.post?
user = User.find(:first, :conditions => [''username = ?'' ,
2015 Jun 30
2
how is the sha fingerprint generated?
...as ssh-keygen
-fl /path/to/key :
#!/usr/bin/env python3
import binascii
import hashlib
import sys
if __name__ == "__main__":
key = binascii.a2b_base64(sys.argv[1])
if sys.argv[2] == "md5":
m = hashlib.new("md5")
m.update(key)
print(m.hexdigest())
elif sys.argv[2] == "sha256":
m = hashlib.new("sha256")
m.update(key)
print(binascii.b2a_base64(m.digest()).decode("utf8")[0:-1])
Do use it in production, do some test, but the general idea is there.
Cheers,
On Tue, 30 Jun 2015 16:12...
2007 Mar 30
7
Some additional attacks on Cookie Session
...ripening and plenty of pesticide.
> Thanks for the fish, all.
>
> jeremy
Anyway, here''s what we came up with:
1. Brute Force
SHA512 can be computed _very_ fast. On my Pentium Core Duo:
irb> z = ''z'' * 100; puts Benchmark.measure { 1000.times
{ Digest::SHA512.hexdigest(z) }}
0.032000 0.000000 0.032000 ( 0.031000)
That''s 0.03 ms/hash using simple Ruby code, not optimized C /
Assembly!
That means a simple brute force attack can go through the entire
dictionary in a few seconds. Even using multiple word phrases, and
inserting several digits, we ca...
2006 Mar 04
4
Two quick newbie questions
...''')
find(:first,
:conditions => [''username = ? and hashed_password =?'',
username, hashed_password])
end
def attempt_login
User.login(self.username, self.password)
end
private
def self.encrypt_password(password)
Digest::SHA1.hexdigest(password)
end
end
... and assuming a form with fields ''name=user[username]'' &
''name=user[password]''. Thanks for the help. Kindly appreciated.
Greg
--
Posted via http://www.ruby-forum.com/.