public static JwtKey LoadKey(byte[] keyBytes, EJwtAlgorithm algorithm, string secret = null, bool isPrivate = false) { switch (algorithm) { case EJwtAlgorithm.HS256: case EJwtAlgorithm.HS384: case EJwtAlgorithm.HS512: return LoadSymmetricKey(keyBytes); case EJwtAlgorithm.RS256: case EJwtAlgorithm.RS384: case EJwtAlgorithm.RS512: return LoadPKCS8Key(keyBytes, secret, isPrivate); default: throw new Exception("Invalid key"); } }
public RsaSha(EJwtAlgorithm method = EJwtAlgorithm.RS256) { switch (method) { case EJwtAlgorithm.RS256: this.method = "SHA-256withRSA"; break; case EJwtAlgorithm.RS384: this.method = "SHA-384withRSA"; break; case EJwtAlgorithm.RS512: this.method = "SHA-512withRSA"; break; default: throw new System.Exception("Invalid Algorithm"); } }
public HmacSha(EJwtAlgorithm method = EJwtAlgorithm.HS256) { switch (method) { case EJwtAlgorithm.HS256: this.method = "HmacSha256"; break; case EJwtAlgorithm.HS384: this.method = "HmacSha384"; break; case EJwtAlgorithm.HS512: this.method = "HmacSha512"; break; default: throw new System.Exception("Invalid Algorithm"); } }