app/models/unidom/common/concerns/aes256_cryptor.rb in unidom-common-1.9.2 vs app/models/unidom/common/concerns/aes256_cryptor.rb in unidom-common-1.10
- old
+ new
@@ -5,13 +5,23 @@
extend ActiveSupport::Concern
included do |includer|
+ ##
+ # 将明文 message 用秘钥 key 进行加密。如:
+ # encrypt 'clear text'
+ # 或
+ # encrypt 'clear text', key: aes256_key
def encrypt(message, key: nil)
self.class.encrypt message, key: key
end
+ ##
+ # 将密文 encoded 用秘钥 key 进行解密。如:
+ # decrypt encoded
+ # 或
+ # decrypt encoded, key: aes256_key
def decrypt(encoded, key: nil)
self.class.decrypt encoded, key: key
end
def aes_256_padding