private static byte[] DecodeBytes(string token, object key = null, JwsAlgorithm?jwsAlg = null, JweAlgorithm?jweAlg = null, JweEncryption?jweEnc = null) { Ensure.IsNotEmpty(token, "Incoming token expected to be in compact serialization form, not empty, whitespace or null.", new object[0]); byte[][] numArray = Compact.Parse(token); if ((int)numArray.Length == 5) { return(JWT.DecryptBytes(numArray, key, jweAlg, jweEnc)); } byte[] numArray1 = numArray[0]; byte[] numArray2 = numArray[1]; byte[] numArray3 = numArray[2]; byte[] bytes = Encoding.UTF8.GetBytes(Compact.Serialize(new byte[][] { numArray1, numArray2 })); string item = (string)JWT.jsMapper.Parse <Dictionary <string, object> >(Encoding.UTF8.GetString(numArray1))["alg"]; if (jwsAlg.HasValue && jwsAlg.Value != JWT.GetHashAlgorithm(item)) { throw new InvalidAlgorithmException("The algorithm type passed to the Decode method did not match the algorithm type in the header."); } if (!JWT.HashAlgorithms[JWT.GetHashAlgorithm(item)].Verify(numArray3, bytes, key)) { throw new IntegrityException("Invalid signature."); } return(numArray2); }
private static string Decrypt(byte[][] parts, object key, JweAlgorithm?jweAlg, JweEncryption?jweEnc) { byte[] numArray = JWT.DecryptBytes(parts, key, jweAlg, jweEnc); return(Encoding.UTF8.GetString(numArray)); }