Hi, I am trying to use crypto-js as well for my hash function and AES function.
Would you please share your experience on how to use it?
I installed successfully the crypto-js library with npm command.
But once I include the following statement into the soure code, the application stop working. let referenceVal = CryptoJS.SHA256(“dsfsdfjksjfsdf”);
Hi Sir,
Thanks a lot for your sharing.
Actually I did try this approach before. However, ionic complains the CrypoJS is not found as a member.
May I know if I missed any steps?
Thanks a lot and looking forward to your reply.
My attention span to read the api was limited to 1 minute. I wasnt convinced I was better off. It isn’t more complicated then that. I had to move on coding.
I will add 15 minutes to the balance to look into it a bit more.
The link in my first post in this thread goes straight to a SHA-256 example that you should be able to adapt within that 15 minutes with time to spare. One gotcha when dealing with WebCrypto, however, is that its Promises are not zone-aware, so you need to wrap them inside Promise.resolve() once in order to get them in the right zone.
I’ve followed your guide and its working on my local machine. But when I git push ionic master, the build processes failed with the error below. Can you please help me with this.
Error: ./src/pages/login/login.ts Module not found: Error: Can’t resolve ‘jssha’ in
‘/usr/src/app/src/pages/login’ resolve ‘jssha’ in ‘/usr/src/app/src/pages/login’ Parsed request is a module
using description file: /usr/src/app/package.json (relative path: ./src/pages/login) Field ‘browser’ doesn’t
contain a valid alias configuration after using description file: /usr/src/app/package.json (relative path:
./src/pages/login) resolve as module looking for modules in /usr/src/app/node_modules using description
file: /usr/src/app/package.json (relative path: ./node_modules) Field ‘browser’ doesn’t contain a valid
alias configuration after using description file: /usr/src/app/package.json (relative path: ./node_modules)
using description file: /usr/src/app/package.json (relative path: ./node_modules/jssha) no extension Field
‘browser’ doesn’t contain a valid alias configuration /usr/src/app/node_modules/jssha doesn’t exist .ts
Field ‘browser’ doesn’t contain a valid alias configuration /usr/src/app/node_modules/jssha.ts doesn’t exist
.js Field ‘browser’ doesn’t contain a valid alias configuration /usr/src/app/node_modules/jssha.js doesn’t
exist .json Field ‘browser’ doesn’t contain a valid alias configuration /usr/src/app/node_modules/jssha.json
doesn’t exist as directory /usr/src/app/node_modules/jssha doesn’t exist [/usr/src/app/node_modules/jssha]
[/usr/src/app/node_modules/jssha.ts] [/usr/src/app/node_modules/jssha.js]
[/usr/src/app/node_modules/jssha.json] [/usr/src/app/node_modules/jssha] @ ./src/pages/login/login.ts
13:0-26 @ ./src/pages/login/login.module.ts @ ./src lazy @
./node_modules/ionic-angular/util/ng-module-loader.js @ ./node_modules/ionic-angular/util/module-loader.js @
./node_modules/ionic-angular/components/popover/popover-component.js @ ./node_modules/ionic-angular/index.js
@ ./src/app/app.module.ts @ ./src/app/main.ts
Error: ./src/pages/login/login.ts
Module not found: Error: Can’t resolve ‘jssha’ in ‘/usr/src/app/src/pages/login’
resolve ‘jssha’ in ‘/usr/src/app/src/pages/login’
Parsed request is a module
using description file: /usr/src/app/package.json (relative path: ./src/pages/login)
Field ‘browser’ doesn’t contain a valid alias configuration
after using description file: /usr/src/app/package.json (relative path: ./src/pages/login)
resolve as module
looking for modules in /usr/src/app/node_modules
using description file: /usr/src/app/package.json (relative path: ./node_modules)
Field ‘browser’ doesn’t contain a valid alias configuration
after using description file: /usr/src/app/package.json (relative path: ./node_modules)
using description file: /usr/src/app/package.json (relative path: ./node_modules/jssha)
no extension
Field ‘browser’ doesn’t contain a valid alias configuration
/usr/src/app/node_modules/jssha doesn’t exist
.ts
Field ‘browser’ doesn’t contain a valid alias configuration
/usr/src/app/node_modules/jssha.ts doesn’t exist
.js
Field ‘browser’ doesn’t contain a valid alias configuration
/usr/src/app/node_modules/jssha.js doesn’t exist
.json
Field ‘browser’ doesn’t contain a valid alias configuration
/usr/src/app/node_modules/jssha.json doesn’t exist
as directory
/usr/src/app/node_modules/jssha doesn’t exist
Hello is https://www.npmjs.com/package/jssha still working in latest ionic version. Please let me know, I would like to implement this in mine project.
I tried to use WebCrypto, but a user in China is getting a “Cryptography API not supported” error in an iOs build. To your knowledge, are you aware of any restrictions of the WebCrypto API?