rsa.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. export function idCardNoFn(data) {
  2. return new Promise(resolve => {
  3. const app = getApp();
  4. const {
  5. appPublicKey
  6. } = app.globalData;
  7. const value = (typeof data).toLocaleLowerCase() === 'string' ? data : JSON.stringify(data);
  8. const textValue = JSON.parse(value);
  9. const idCardNo = textValue.idCardNo || '';
  10. const params = {
  11. text: idCardNo,
  12. action: 'encrypt',
  13. key: appPublicKey
  14. };
  15. my.rsa({ ...params,
  16. fail: () => resolve(''),
  17. success: ({
  18. text
  19. }) => resolve(text)
  20. });
  21. });
  22. }
  23. export function mobileFn(data) {
  24. return new Promise(resolve => {
  25. const app = getApp();
  26. const {
  27. appPublicKey
  28. } = app.globalData;
  29. const value = (typeof data).toLocaleLowerCase() === 'string' ? data : JSON.stringify(data);
  30. const textValue = JSON.parse(value);
  31. const mobile = textValue.mobile || '';
  32. const params = {
  33. text: mobile,
  34. action: 'encrypt',
  35. key: appPublicKey
  36. };
  37. my.rsa({ ...params,
  38. fail: () => resolve(''),
  39. success: ({
  40. text
  41. }) => resolve(text)
  42. });
  43. });
  44. }