Skip to content

ducreyna/java-jwt-simple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-jwt-simple

Java implementation of JSON Web Tokens. An easy way to encode and decode a JWT with Java.

Hashing algorithms

  • SHA256
  • SHA384
  • SHA512

Dependencies

Additional libraries

JUnit

How to use

import com.ducreyna.jwt;

String key = "secret";

try {
	// Encode a JWT with default algorithm
	HashMap<String, Object> payload = new HashMap<String, Object>();
	payload.put("name", "ducreyna");
	payload.put("admin", true);
	payload.put("state", new HashMap<String, Object>());

	String token = Jwt.encode(payload, key);


	// Encode a JWT with an algorithm of your choice
	HashMap<String, Object> payload = new HashMap<String, Object>();
	payload.put("name", "ducreyna");

	String token = Jwt.encode(payload, key, Algorithm.HS512);


	// Decode a JWT with signature verification
	Map<String, Object> decoded = Jwt.decode(token, key, true);
}
catch(Exception e) {}

About

Java implementation of JSON Web Tokens

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages