{"action":"closed","issue":{"url":"https://api.github.com/repos/jokecamp/jokecamp.com/issues/13","repository_url":"https://api.github.com/repos/jokecamp/jokecamp.com","labels_url":"https://api.github.com/repos/jokecamp/jokecamp.com/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/jokecamp/jokecamp.com/issues/13/comments","events_url":"https://api.github.com/repos/jokecamp/jokecamp.com/issues/13/events","html_url":"https://github.com/jokecamp/jokecamp.com/issues/13","id":298864282,"number":13,"title":"HMAC SHA256 | issue in Java example ","user":{"login":"Atifmahmood12","id":14121054,"avatar_url":"https://avatars0.githubusercontent.com/u/14121054?v=4","gravatar_id":"","url":"https://api.github.com/users/Atifmahmood12","html_url":"https://github.com/Atifmahmood12","followers_url":"https://api.github.com/users/Atifmahmood12/followers","following_url":"https://api.github.com/users/Atifmahmood12/following{/other_user}","gists_url":"https://api.github.com/users/Atifmahmood12/gists{/gist_id}","starred_url":"https://api.github.com/users/Atifmahmood12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Atifmahmood12/subscriptions","organizations_url":"https://api.github.com/users/Atifmahmood12/orgs","repos_url":"https://api.github.com/users/Atifmahmood12/repos","events_url":"https://api.github.com/users/Atifmahmood12/events{/privacy}","received_events_url":"https://api.github.com/users/Atifmahmood12/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-02-21T07:17:58Z","updated_at":"2018-02-22T13:40:41Z","closed_at":"2018-02-22T13:40:41Z","author_association":"NONE","body":"https://github.com/jokecamp/jokecamp.com/commit/2d9f0734ae437b6d2d0603bc13c9f94435e1df89\r\n\r\n**Curernt example:** \r\n\r\n```\r\nimport javax.crypto.Mac;\r\nimport javax.crypto.spec.SecretKeySpec;\r\nimport org.apache.commons.codec.binary.Base64;\r\n\r\npublic class ApiSecurityExample {\r\n  public static void main(String[] args) {\r\n    try {\r\n     String secret = \"secret\";\r\n     String message = \"Message\";\r\n\r\n     Mac sha256_HMAC = Mac.getInstance(\"HmacSHA256\");\r\n     SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), \"HmacSHA256\");\r\n     sha256_HMAC.init(secret_key);\r\n\r\n     String hash = Base64.encodeBase64String(sha256_HMAC.doFinal(message.getBytes()));\r\n     System.out.println(hash);\r\n    }\r\n    catch (Exception e){\r\n     System.out.println(\"Error\");\r\n    }\r\n   }\r\n}\r\n```\r\n\r\n\r\n**Correction in Example:**\r\n\r\n```\r\nimport javax.crypto.Mac;\r\nimport javax.crypto.spec.SecretKeySpec;\r\nimport org.apache.commons.codec.binary.Base64;\r\n\r\npublic class ApiSecurityExample {\r\n  public static void main(String[] args) {\r\n    try {\r\n     String secret = \"secret\";\r\n     String message = \"Message\";\r\n\r\n     Mac sha256_HMAC = Mac.getInstance(\"HmacSHA256\");\r\n     SecretKeySpec secret_key = new SecretKeySpec(**Base64.decode**(secret.getBytes()), \"HmacSHA256\");\r\n     sha256_HMAC.init(secret_key);\r\n\r\n     String hash = Base64.encodeBase64String(sha256_HMAC.doFinal(message.getBytes()));\r\n     System.out.println(hash);\r\n    }\r\n    catch (Exception e){\r\n     System.out.println(\"Error\");\r\n    }\r\n   }\r\n}\r\n```\r\n\r\n**Note:** Please correct it in the documentation. \r\n\r\n\r\n"}}
{"actor":{"display_login":"jokecamp"}}