##// END OF EJS Templates
remove trailing white-spaces from lib/redmine/ciphering.rb....
Toshi MARUYAMA -
r6824:54ae8de42be1
parent child
Show More
@@ -17,10 +17,10
17 17
18 18 module Redmine
19 19 module Ciphering
20 def self.included(base)
20 def self.included(base)
21 21 base.extend ClassMethods
22 22 end
23
23
24 24 class << self
25 25 def encrypt_text(text)
26 26 if cipher_key.blank?
@@ -36,7 +36,7 module Redmine
36 36 "aes-256-cbc:" + [e, iv].map {|v| Base64.encode64(v).strip}.join('--')
37 37 end
38 38 end
39
39
40 40 def decrypt_text(text)
41 41 if text && match = text.match(/\Aaes-256-cbc:(.+)\Z/)
42 42 text = match[1]
@@ -51,13 +51,13 module Redmine
51 51 text
52 52 end
53 53 end
54
54
55 55 def cipher_key
56 56 key = Redmine::Configuration['database_cipher_key'].to_s
57 57 key.blank? ? nil : Digest::SHA256.hexdigest(key)
58 58 end
59 59 end
60
60
61 61 module ClassMethods
62 62 def encrypt_all(attribute)
63 63 transaction do
@@ -68,7 +68,7 module Redmine
68 68 end
69 69 end ? true : false
70 70 end
71
71
72 72 def decrypt_all(attribute)
73 73 transaction do
74 74 all.each do |object|
@@ -79,14 +79,14 module Redmine
79 79 end
80 80 end ? true : false
81 81 end
82
82
83 83 private
84
84
85 85 # Returns the value of the given ciphered attribute
86 86 def read_ciphered_attribute(attribute)
87 87 Redmine::Ciphering.decrypt_text(read_attribute(attribute))
88 88 end
89
89
90 90 # Sets the value of the given ciphered attribute
91 91 def write_ciphered_attribute(attribute, value)
92 92 write_attribute(attribute, Redmine::Ciphering.encrypt_text(value))
General Comments 0
You need to be logged in to leave comments. Login now