const getEncryptStr = value => new Promise(resolve => {
  const app = getApp();
  const {
    appPublicKey
  } = app.globalData;

  if (!appPublicKey || !value) {
    return resolve(value);
  }

  const params = {
    text: value,
    action: 'encrypt',
    key: appPublicKey
  };
  my.rsa({ ...params,
    fail: () => resolve(value),
    success: ({
      text
    }) => resolve(text)
  });
});

export default getEncryptStr;