summaryrefslogtreecommitdiffstats
path: root/lib/redmine/ciphering.rb
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-09-01 00:48:43 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-09-01 00:48:43 +0000
commit54ae8de42be10a6d9f32b3ff7acf5ed63f435a79 (patch)
treed6a339e47d9a5bb23773dc02cf2268735bee0cf3 /lib/redmine/ciphering.rb
parent7d26d8167b19cf50470720cb2fcddecf378a97b7 (diff)
downloadredmine-54ae8de42be10a6d9f32b3ff7acf5ed63f435a79.tar.gz
redmine-54ae8de42be10a6d9f32b3ff7acf5ed63f435a79.zip
remove trailing white-spaces from lib/redmine/ciphering.rb.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6944 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/ciphering.rb')
-rw-r--r--lib/redmine/ciphering.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/redmine/ciphering.rb b/lib/redmine/ciphering.rb
index 8efe37c29..2fb2dca86 100644
--- a/lib/redmine/ciphering.rb
+++ b/lib/redmine/ciphering.rb
@@ -17,10 +17,10 @@
module Redmine
module Ciphering
- def self.included(base)
+ def self.included(base)
base.extend ClassMethods
end
-
+
class << self
def encrypt_text(text)
if cipher_key.blank?
@@ -36,7 +36,7 @@ module Redmine
"aes-256-cbc:" + [e, iv].map {|v| Base64.encode64(v).strip}.join('--')
end
end
-
+
def decrypt_text(text)
if text && match = text.match(/\Aaes-256-cbc:(.+)\Z/)
text = match[1]
@@ -51,13 +51,13 @@ module Redmine
text
end
end
-
+
def cipher_key
key = Redmine::Configuration['database_cipher_key'].to_s
key.blank? ? nil : Digest::SHA256.hexdigest(key)
end
end
-
+
module ClassMethods
def encrypt_all(attribute)
transaction do
@@ -68,7 +68,7 @@ module Redmine
end
end ? true : false
end
-
+
def decrypt_all(attribute)
transaction do
all.each do |object|
@@ -79,14 +79,14 @@ module Redmine
end
end ? true : false
end
-
+
private
-
+
# Returns the value of the given ciphered attribute
def read_ciphered_attribute(attribute)
Redmine::Ciphering.decrypt_text(read_attribute(attribute))
end
-
+
# Sets the value of the given ciphered attribute
def write_ciphered_attribute(attribute, value)
write_attribute(attribute, Redmine::Ciphering.encrypt_text(value))