【问题标题】:Redux-Persist Secure EncryptionRedux-Persist 安全加密
【发布时间】:2018-03-03 21:39:04
【问题描述】:

我正在尝试学习如何在我的 react-native 应用程序中安全地保存我的 redux 状态。

我正在使用 redux-persist-transform-encrypt 根据文档:https://github.com/maxdeviant/redux-persist-transform-encrypt

import { persistReducer } from 'redux-persist'
import createEncryptor from 'redux-persist-transform-encrypt'

const encryptor = createEncryptor({
  secretKey: 'my-super-secret-key'
})

const reducer = persistReducer(
  {
    transforms: [encryptor]
  },
  baseReducer
)

但我不知道如何安全地设置secretKey 字符串'my-super-secret-key'

js编译的时候,这个字符串的值在bundle中不可见吗?

【问题讨论】:

    标签: react-native encryption asyncstorage redux-persist


    【解决方案1】:

    是的,keys 将在 JS bundle 中可见。要解决此问题,您需要设置 nested persisted states,在redux-persist 中并以某种方式将密钥存储到secured-dbkeystore 或使用here 中提到的这个包。

    const mainPersistConfig = {
      key: "main",
      storage: AsyncStorage,
      blacklist: ["yourKeyReducer"]
    };
    
    const tokenPersistConfig = {
      key: "token",
      storage: sensitiveStorage
    };
    

    由于它提供了creation of the sensitive storage,因此安全问题得到了解决。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-30
    • 1970-01-01
    • 2020-07-12
    • 1970-01-01
    • 2023-02-21
    • 1970-01-01
    • 2018-08-28
    • 2021-06-03
    相关资源
    最近更新 更多