Module: CaptchaUtil

Extended by:
CaptchaUtil
Included in:
CaptchaUtil
Defined in:
lib/captcha3/captcha_util.rb

Instance Method Summary collapse

Instance Method Details

#encrypt_string(str) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/captcha3/captcha_util.rb', line 10

def encrypt_string(str)
	if defined?(CAPTCHA_SALT)
		salt = CAPTCHA_SALT
	else
		raise "---You must add CAPTCHA_SALT in config/initializers/captcha3.rb---"
	end 
	Digest::SHA256.hexdigest("#{salt}#{str}")
end

#random_imageObject



5
6
7
8
# File 'lib/captcha3/captcha_util.rb', line 5

def random_image
	@@captcha_files = Dir.glob("#{Rails.root}/public/system/captcha3/*.*").map{ |f| File.basename(f)}
	@@captcha_files[rand(@@captcha_files.size)]
end