# Ionic 2 to generate sha512 code

**URL:** <https://forum.ionicframework.com/t/ionic-2-to-generate-sha512-code/84083>\
**Category:** ionic-v3\
**Created:** [March 24, 2017, 10:08am UTC](https://forum.ionicframework.com/t/ionic-2-to-generate-sha512-code/84083 "2017-03-24T10:08:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajana](https://avatars.discourse-cdn.com/v4/letter/r/8baadc/32.png) [@rajana](https://forum.ionicframework.com/u/rajana)\
**Post date:** [March 24, 2017, 10:08am UTC](https://forum.ionicframework.com/t/ionic-2-to-generate-sha512-code/84083/1 "2017-03-24T10:08:44Z")

</div>

Hi,

How to generate sha512 code in ionic 2.

Thanks.

---

<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:** [March 24, 2017, 8:36pm UTC](https://forum.ionicframework.com/t/ionic-2-to-generate-sha512-code/84083/2 "2017-03-24T20:36:20Z")

</div>

I would use [WebCrypto](https://www.w3.org/TR/WebCryptoAPI/):

```auto
let data: Uint8Array = [whatever];
crypto.subtle.digest({name: "SHA-512"}, data).then((hash) => {
  hash is an ArrayBuffer of the SHA-512 digest
});

```

---

<div class="post-metadata">

**Author:** ![viniciusmaran](https://avatars.discourse-cdn.com/v4/letter/v/8e7dd6/32.png) [@viniciusmaran](https://forum.ionicframework.com/u/viniciusmaran)\
**Post date:** [October 31, 2018, 8:00pm UTC](https://forum.ionicframework.com/t/ionic-2-to-generate-sha512-code/84083/3 "2018-10-31T20:00:08Z")

</div>

Worked with iOS, but I got “Cannot read property ‘digest’ of undefined” on Android.

any idea?

---

<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:** [October 31, 2018, 8:04pm UTC](https://forum.ionicframework.com/t/ionic-2-to-generate-sha512-code/84083/4 "2018-10-31T20:04:00Z")

</div>

Perhaps if Android stock webview is really old on that device, it might not have subtlecrypto. You could try using the wkwebviewengine plugin.
