# Which algorithm is best for security?

**URL:** <https://community.auth0.com/t/which-algorithm-is-best-for-security/8422>\
**Category:** Get Help\
**Tags:** tier1, go, algorithm\
**Created:** [October 9, 2017, 12:06pm UTC](https://community.auth0.com/t/which-algorithm-is-best-for-security/8422 "2017-10-09T12:06:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![swatinaag](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@swatinaag](https://community.auth0.com/u/swatinaag)\
**Post date:** [October 9, 2017, 12:06pm UTC](https://community.auth0.com/t/which-algorithm-is-best-for-security/8422/1 "2017-10-09T12:06:55Z")

</div>

Hello,  
I have a backend application in go and I am using jwt authentication method for my api’s.  
I have two questions:

1. Which one the best algorithm for  
secure an api HS256 or RS256
2. I have created an api using the RS256 algorithm method. When I decode the token string in the Debugger then it decode all the values including the signature then how it is secure?

Also When I decode the token It given the invalid signature error although all the decoded values match with my original values.

---

<div class="post-metadata">

**Author:** ![swapna.dixit](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@swapna.dixit](https://community.auth0.com/u/swapna.dixit)\
**Post date:** [October 9, 2017, 4:32pm UTC](https://community.auth0.com/t/which-algorithm-is-best-for-security/8422/2 "2017-10-09T16:32:17Z")

</div>

You might want to go through the following links for information on both the algorithms, comparison between the two and the best security practices:

- [APIs](https://auth0.com/docs/apis)
- [APIs](https://auth0.com/docs/apis#signing-algorithms)

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [October 10, 2017, 6:05pm UTC](https://community.auth0.com/t/which-algorithm-is-best-for-security/8422/3 "2017-10-10T18:05:50Z")

</div>

In addition to the documentation pointed in the other answer, you mentioned the use of Go and a problem validating the token. There as an issue with a Go library for JWT that would validate that the audience of the token was exactly the same as the one configured which could be a problem in some situation where multiple audiences were present. You can find more information [here](https://github.com/square/go-jose/issues/151).

Another thing to have in mind is that a signed JWT can be represented as multiple base64url-encoded parts separated by a dot character and decoding the base64url data does not by itself guarantee any sort of assurance. In particular, if you need to ensure the token comes from a trusted party you’ll need to validate the signature and not just decode the base64url data.

---

<div class="post-metadata">

**Author:** ![swapna.dixit](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@swapna.dixit](https://community.auth0.com/u/swapna.dixit)\
**Post date:** [October 9, 2017, 4:32pm UTC](https://community.auth0.com/t/which-algorithm-is-best-for-security/8422/4 "2017-10-09T16:32:17Z")

</div>

You might want to go through the following links for information on both the algorithms, comparison between the two and the best security practices:

- [APIs](https://auth0.com/docs/apis)
- [APIs](https://auth0.com/docs/apis#signing-algorithms)

---

<div class="post-metadata">

**Author:** ![swatinaag](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@swatinaag](https://community.auth0.com/u/swatinaag)\
**Post date:** [October 11, 2017, 9:23am UTC](https://community.auth0.com/t/which-algorithm-is-best-for-security/8422/5 "2017-10-11T09:23:36Z")

</div>

Thanks you for your answer!!

---

<div class="post-metadata">

**Author:** ![swatinaag](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@swatinaag](https://community.auth0.com/u/swatinaag)\
**Post date:** [October 11, 2017, 9:24am UTC](https://community.auth0.com/t/which-algorithm-is-best-for-security/8422/6 "2017-10-11T09:24:34Z")

</div>

Thank you for your reply on my question.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/which-algorithm-is-best-for-security/8422/7 "2018-03-02T05:56:52Z")

</div>


