跳至内容 跳至搜索

一个 NullEncryptor,在尝试加密数据时会抛出错误

这在您想公开密文以进行调试,并希望确保不会用错误的内容覆盖任何可加密属性时很有用。

方法
D
E

实例公共方法

解密(encrypted_text, key_provider: nil, cipher_options: {})

# File activerecord/lib/active_record/encryption/read_only_null_encryptor.rb, line 15
def decrypt(encrypted_text, key_provider: nil, cipher_options: {})
  encrypted_text
end

加密(clean_text, key_provider: nil, cipher_options: {})

# File activerecord/lib/active_record/encryption/read_only_null_encryptor.rb, line 11
def encrypt(clean_text, key_provider: nil, cipher_options: {})
  raise Errors::Encryption, "This encryptor is read-only"
end

已加密?(text)

# File activerecord/lib/active_record/encryption/read_only_null_encryptor.rb, line 19
def encrypted?(text)
  false
end