【问题标题】:Encrypting in Rails and decrypting in Salesforce在 Rails 中加密和在 Salesforce 中解密
【发布时间】:2019-01-25 04:05:34
【问题描述】:

我在 Rails 项目中使用 attr_encrypted gem,并在 PostgreSQL 数据库中加密银行帐号。在数据库中,我有两列(encrypted_bank_account 和 encrypted_bank_account_iv)用于加密数据。我的 payment_method 模型文件中有这一行:

attr_encrypted :account_number, key: ENV['ACCOUNT_KEY'], encode: true, encode_iv: true, algorithm: 'aes-256-cbc'

我希望能够将此加密数据发送给 SalesForce,对其进行解密并将其存储在 SalesForce 对象中。我不确定当它到达那里时如何解密它并且可以使用一些建议。谢谢!

【问题讨论】:

    标签: ruby-on-rails encryption salesforce


    【解决方案1】:

    在 Salesforce 上有一个端点,用于获取数据并在

    中解密
    // Normally this key should be stored in a protected custom setting 
    // or an encrypted field on a custom object
    Blob cryptoKey = Crypto.generateAesKey(256);
    
    // Generate the data to be encrypted.
    Blob data = Blob.valueOf('Test data to encrypted');
    // Encrypt the data and have Salesforce.com generate the initialization vector
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    // Decrypt the data - the first 16 bytes contain the initialization vector
    Blob decryptedData = Crypto.decryptWithManagedIV('AES256', cryptoKey, encryptedData);
    
    // Decode the decrypted data for subsequent use
    String decryptedDataString = decryptedData.toString();
    
    
    https://developer.salesforce.com/page/Apex_Crypto_Class 
    

    【讨论】:

      猜你喜欢
      • 2018-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-27
      • 1970-01-01
      • 2013-02-12
      相关资源
      最近更新 更多