# Exemple HMAC-256 sur la page officielle SSO

**URL:** <https://meta.discourse.org/t/hmac-256-example-on-official-sso-page/92546>\
**Category:** SSO\
**Created:** [Juillet 17, 2018, 3:08 UTC](https://meta.discourse.org/t/hmac-256-example-on-official-sso-page/92546 "2018-07-17T15:08:00Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![jehrlich](https://avatars.discourse-cdn.com/v4/letter/j/f05b48/32.png) [@jehrlich](https://meta.discourse.org/u/jehrlich)\
**Post date:** [Juillet 18, 2018, 9:25 UTC](https://meta.discourse.org/t/hmac-256-example-on-official-sso-page/92546/3 "2018-07-18T21:25:02Z")

</div>

The problem seems to be in the example, not the code, presumably a cut/paste error.  
**Current Version:**

- Raw payload is generated: `nonce=cb68251eefb5211e58c00ff1395f0c0b`

- Payload is Base64 encoded: `bm9uY2U9Y2I2ODI1MWVlZmI1MjExZTU4YzAwZmYxMzk1ZjBjMGI=\n`

- Payload is URL encoded: `bm9uY2U9Y2I2ODI1MWVlZmI1MjExZTU4YzAwZmYxMzk1ZjBjMGI%3D%0A`

- HMAC-SHA256 is generated on the Base64 encoded Payload: `2828aa29899722b35a2f191d34ef9b3ce695e0e6eeec47deb46d588d70c7cb56`

I believe this should be as below. Note removal of last char on bas64 and URL encoded strings. Two online HMAC-SHA256 testers agree on the generated HMAC-SHA256 of 1ce1494f94484b6f6a092be9b15ccc1cdafb1f8460a3838fbb0e0883c4390471 on input data of bm9uY2U9Y2I2ODI1MWVlZmI1MjExZTU4YzAwZmYxMzk1ZjBjMGI= with key d836444a9e4084d5b224a60c208dce14

**Suggested revision**

- Raw payload is generated: `nonce=cb68251eefb5211e58c00ff1395f0c0b`

- Payload is Base64 encoded: `bm9uY2U9Y2I2ODI1MWVlZmI1MjExZTU4YzAwZmYxMzk1ZjBjMGI=`

- Payload is URL encoded: `bm9uY2U9Y2I2ODI1MWVlZmI1MjExZTU4YzAwZmYxMzk1ZjBjMGI%3D`

- HMAC-SHA256 is generated on the Base64 encoded Payload: `1ce1494f94484b6f6a092be9b15ccc1cdafb1f8460a3838fbb0e0883c4390471`

---

_[View the full topic](https://meta.discourse.org/t/hmac-256-example-on-official-sso-page/92546)._
