<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Generate Hmac token using secret key in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/Generate-Hmac-token-using-secret-key/m-p/100092#M47495</link>
    <description>Hi &lt;A class="user-content-mention" data-sign="@" data-contactkey="d666ed23-eedd-4996-bd6b-3bed96e53a93" data-tag-text="@Manish Rawat" href="https://community.blueprism.com/network/profile?UserKey=d666ed23-eedd-4996-bd6b-3bed96e53a93" data-itemmentionkey="398506eb-3a99-486e-a323-5229f43761fc"&gt;@Manish Rawat&lt;/A&gt;,&lt;BR /&gt;&lt;BR /&gt;In my experience, if you're trying to create something similar to jwt.io then you're looking at create a JWT (Json Web Token). The best way to do that, is to use an existing library. The one I've used in the past is &lt;A href="https://github.com/jwt-dotnet/jwt" target="_blank" rel="noopener"&gt;JWT.Net&lt;/A&gt; along with &lt;A href="https://www.bouncycastle.org/csharp/" target="_blank" rel="noopener"&gt;BouncyCastle&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;Take a look at &lt;A href="https://community.blueprism.com/question/jws-signature-issue-if-body-contains-special-chracters#1c7f1489-2967-41cf-860f-b1bb8cb1debd" target="_blank" rel="noopener"&gt;this&lt;/A&gt; thread and you should see some example code I posted towards the end of the thread.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Eric&lt;BR /&gt;&lt;BR /&gt;​</description>
    <pubDate>Wed, 03 Aug 2022 15:23:02 GMT</pubDate>
    <dc:creator>ewilson</dc:creator>
    <dc:date>2022-08-03T15:23:02Z</dc:date>
    <item>
      <title>Generate Hmac token using secret key</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Generate-Hmac-token-using-secret-key/m-p/100087#M47490</link>
      <description>Hi. I need to create a hmac token using a secret key. I would really appreciate if someone could please provide the code. Many thanks!</description>
      <pubDate>Fri, 14 Jan 2022 18:17:40 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Generate-Hmac-token-using-secret-key/m-p/100087#M47490</guid>
      <dc:creator>KimDougan</dc:creator>
      <dc:date>2022-01-14T18:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Hmac token using secret key</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Generate-Hmac-token-using-secret-key/m-p/100088#M47491</link>
      <description>&lt;A class="user-content-mention" data-sign="@" data-contactkey="0c6be217-9ca3-4f6f-a05b-d52e59916bd6" data-tag-text="@Kim Dougan" href="https://community.blueprism.com/network/profile?UserKey=0c6be217-9ca3-4f6f-a05b-d52e59916bd6" data-itemmentionkey="35f28013-c188-4122-8629-947c12740cb4"&gt;@Kim Dougan&lt;/A&gt;,&lt;BR /&gt;&lt;BR /&gt;You're going to have to provide a bit more information. You say a "hmac token". Do you mean an "HMAC signature"? Is this something you need to apply to a web request? Do you know what type of HMAC? Are we talking HMAC-256, HMAC-MD5, etc.&lt;BR /&gt;&lt;BR /&gt;You can find more details about the HMAC capability of .NET &lt;A href="https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.hmac?view=netframework-4.8" target="_blank" rel="noopener"&gt;here&lt;/A&gt;. Ultimately, this is what would be used within a Code stage or Global Code page to generate your HMAC signature.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Eric​</description>
      <pubDate>Fri, 14 Jan 2022 20:48:29 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Generate-Hmac-token-using-secret-key/m-p/100088#M47491</guid>
      <dc:creator>ewilson</dc:creator>
      <dc:date>2022-01-14T20:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Hmac token using secret key</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Generate-Hmac-token-using-secret-key/m-p/100089#M47492</link>
      <description>&lt;a href="https://community.blueprism.com/t5/user/viewprofilepage/user-id/833"&gt;@ewilson&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you​ for replying.&lt;BR /&gt;&lt;BR /&gt;Yes - it is a HMAC signature using SHA 256. It will be used for an api call between my company and a third party.&lt;BR /&gt;&lt;BR /&gt;many thanks&lt;BR /&gt;Kim</description>
      <pubDate>Fri, 14 Jan 2022 23:22:48 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Generate-Hmac-token-using-secret-key/m-p/100089#M47492</guid>
      <dc:creator>KimDougan</dc:creator>
      <dc:date>2022-01-14T23:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Hmac token using secret key</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Generate-Hmac-token-using-secret-key/m-p/100090#M47493</link>
      <description>&lt;A class="user-content-mention" data-sign="@" data-contactkey="0c6be217-9ca3-4f6f-a05b-d52e59916bd6" data-tag-text="@Kim Dougan" href="https://community.blueprism.com/network/profile?UserKey=0c6be217-9ca3-4f6f-a05b-d52e59916bd6" data-itemmentionkey="3a761cbb-7665-4801-8118-dccd68e98997"&gt;@Kim Dougan&lt;/A&gt;,&lt;BR /&gt;&lt;BR /&gt;Without knowing the 3rd party platform and it's expectations for the content of the message, the best I can offer are some examples.&lt;BR /&gt;&lt;BR /&gt;This is probably the most basic example of computing an HMAC256 hash for a signature:&lt;BR /&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt;private string GetHMAC(string text, string key)
{
  key = key ?? "";

  using (var hmacsha256 = new HMACSHA256(Encoding.UTF8.GetBytes(key)))
  {
    var hash = hmacsha256.ComputeHash(Encoding.UTF8.GetBytes(text));
    return Convert.ToBase64String(hash);
  }
}​&lt;/CODE&gt;&lt;/PRE&gt;
​&lt;BR /&gt;You'll need to add a reference to the assembly &lt;STRONG&gt;mscorlib.dll&lt;/STRONG&gt; and the namespace &lt;STRONG&gt;System.Security.Cryptography&lt;/STRONG&gt; in your &lt;STRONG&gt;Code Options&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;If you grab a copy of the &lt;A href="https://digitalexchange.blueprism.com/dx/entry/9648/solution/aws-rest-api-utility" target="_blank" rel="noopener"&gt;Blue Prism AWS REST Utility&lt;/A&gt; VBO from the Digital Exchange, there's a more complex example of how to calculate an HMAC256 signature for requests to AWS services. This is an example where the platform (AWS in this case) has specific expectations regarding the various bits of data that should be included in the signature.&lt;BR /&gt;&lt;BR /&gt;There are some additional examples on this &lt;A href="https://stackoverflow.com/questions/12185122/calculating-hmacsha256-using-c-sharp-to-match-payment-provider-example" target="_blank" rel="noopener"&gt;Stack Overflow&lt;/A&gt; thread.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Eric</description>
      <pubDate>Sat, 15 Jan 2022 00:11:33 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Generate-Hmac-token-using-secret-key/m-p/100090#M47493</guid>
      <dc:creator>ewilson</dc:creator>
      <dc:date>2022-01-15T00:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Hmac token using secret key</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Generate-Hmac-token-using-secret-key/m-p/100091#M47494</link>
      <description>Hi &lt;a href="https://community.blueprism.com/t5/user/viewprofilepage/user-id/833"&gt;@ewilson&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;I am trying also trying to create the HAMC-256 signature with the below requirement from the &lt;A href="https://jwt.io" target="test_blank"&gt;https://jwt.io&lt;/A&gt; :&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="36386.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/36396i53FAF8475BF08B53/image-size/large?v=v2&amp;amp;px=999" role="button" title="36386.png" alt="36386.png" /&gt;&lt;/span&gt;&lt;BR /&gt;Please not that the "secret base64 encoded" checkbox is checked.&lt;BR /&gt;&lt;BR /&gt;Any idea/code like below in how I can achieve that?&lt;BR /&gt;&lt;BR /&gt;I have the header, payload and encryption key details with me.</description>
      <pubDate>Wed, 03 Aug 2022 12:43:28 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Generate-Hmac-token-using-secret-key/m-p/100091#M47494</guid>
      <dc:creator>ManishRaw</dc:creator>
      <dc:date>2022-08-03T12:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Hmac token using secret key</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Generate-Hmac-token-using-secret-key/m-p/100092#M47495</link>
      <description>Hi &lt;A class="user-content-mention" data-sign="@" data-contactkey="d666ed23-eedd-4996-bd6b-3bed96e53a93" data-tag-text="@Manish Rawat" href="https://community.blueprism.com/network/profile?UserKey=d666ed23-eedd-4996-bd6b-3bed96e53a93" data-itemmentionkey="398506eb-3a99-486e-a323-5229f43761fc"&gt;@Manish Rawat&lt;/A&gt;,&lt;BR /&gt;&lt;BR /&gt;In my experience, if you're trying to create something similar to jwt.io then you're looking at create a JWT (Json Web Token). The best way to do that, is to use an existing library. The one I've used in the past is &lt;A href="https://github.com/jwt-dotnet/jwt" target="_blank" rel="noopener"&gt;JWT.Net&lt;/A&gt; along with &lt;A href="https://www.bouncycastle.org/csharp/" target="_blank" rel="noopener"&gt;BouncyCastle&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;Take a look at &lt;A href="https://community.blueprism.com/question/jws-signature-issue-if-body-contains-special-chracters#1c7f1489-2967-41cf-860f-b1bb8cb1debd" target="_blank" rel="noopener"&gt;this&lt;/A&gt; thread and you should see some example code I posted towards the end of the thread.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Eric&lt;BR /&gt;&lt;BR /&gt;​</description>
      <pubDate>Wed, 03 Aug 2022 15:23:02 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Generate-Hmac-token-using-secret-key/m-p/100092#M47495</guid>
      <dc:creator>ewilson</dc:creator>
      <dc:date>2022-08-03T15:23:02Z</dc:date>
    </item>
  </channel>
</rss>

