# Can I use sha256 function in Ionic?

**URL:** <https://forum.ionicframework.com/t/can-i-use-sha256-function-in-ionic/69418>\
**Category:** ionic-v3\
**Created:** [November 7, 2016, 2:19pm UTC](https://forum.ionicframework.com/t/can-i-use-sha256-function-in-ionic/69418 "2016-11-07T14:19:38Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [July 12, 2018, 6:41pm UTC](https://forum.ionicframework.com/t/can-i-use-sha256-function-in-ionic/69418/21 "2018-07-12T18:41:58Z")

</div>

> [@alexasilock](#):
>
> are you aware of any restrictions of the WebCrypto API?

If the iOS Safari version is sufficiently old (like \<10), its implementation may be wonky. If you are using [WkWebview](https://github.com/apache/cordova-plugin-wkwebview-engine), that may help. You could also look at [webcrypto-shim](https://github.com/vibornoff/webcrypto-shim).

---

<div class="post-metadata">

**Author:** ![alexasilock](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@alexasilock](https://forum.ionicframework.com/u/alexasilock)\
**Post date:** [July 13, 2018, 7:24am UTC](https://forum.ionicframework.com/t/can-i-use-sha256-function-in-ionic/69418/22 "2018-07-13T07:24:29Z")

</div>

> [@rapropos](#):
>
> > Loading…
> 
> If the iOS Safari version is sufficiently old (like \<10), its implementation may be wonky. If you are using [WkWebview](https://github.com/apache/cordova-plugin-wkwebview-engine), that may help. You could also look at [webcrypto-shim](https://github.com/vibornoff/webcrypto-shim).

Thanks much appreciated!

---

<div class="post-metadata">

**Author:** ![hizagi](https://avatars.discourse-cdn.com/v4/letter/h/a183cd/32.png) [@hizagi](https://forum.ionicframework.com/u/hizagi)\
**Post date:** [January 26, 2019, 3:28pm UTC](https://forum.ionicframework.com/t/can-i-use-sha256-function-in-ionic/69418/23 "2019-01-26T15:28:58Z")

</div>

Hi, im trying to use the WebCrypto API but im having a little difficult converting string to ArrayBuffer, do you have any hint on that?

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [January 26, 2019, 6:13pm UTC](https://forum.ionicframework.com/t/can-i-use-sha256-function-in-ionic/69418/24 "2019-01-26T18:13:29Z")

</div>

The [js-jose library](https://github.com/square/js-jose/blob/master/lib/jose-utils.js) has some utility functions that do that; look for `arrayFromString()` and `stringFromArray()`.

---

<div class="post-metadata">

**Author:** ![hizagi](https://avatars.discourse-cdn.com/v4/letter/h/a183cd/32.png) [@hizagi](https://forum.ionicframework.com/u/hizagi)\
**Post date:** [January 28, 2019, 2:45pm UTC](https://forum.ionicframework.com/t/can-i-use-sha256-function-in-ionic/69418/25 "2019-01-28T14:45:20Z")

</div>

i used the functions and it works now, but i still have a problem, when i use “ionic cordova run” command to debug the app, the crypto.subtle object is undefined, when i use “ionic cordova build” command, the WebCrypto works fine… it should be that way?

---

<div class="post-metadata">

**Author:** ![climax0013](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@climax0013](https://forum.ionicframework.com/u/climax0013)\
**Post date:** [June 4, 2019, 4:41pm UTC](https://forum.ionicframework.com/t/can-i-use-sha256-function-in-ionic/69418/26 "2019-06-04T16:41:37Z")

</div>

Gracias, me ayudó mucho tu código. Solo que en ionic 4 tuve que usar

```auto
import * as CryptoJS from 'crypto-js';

```

Muchas gracias.

[Previous page](https://forum.ionicframework.com/t/can-i-use-sha256-function-in-ionic/69418.md?page=1)
