//if we alread have the alg, we assume that the creds have been validated already,
        //to save the expense of validating twice in the create function...
        private static byte[] GetSignature(JWTHeader header, JWTPayload payload, JWTAlgorithm alg, VssSigningCredentials signingCredentials)
        {
            if (alg == JWTAlgorithm.None)
            {
                return(null);
            }

            ArgumentUtility.CheckForNull(header, nameof(header));
            ArgumentUtility.CheckForNull(payload, nameof(payload));

            string encoding = string.Format("{0}.{1}", header.JsonEncode(), payload.JsonEncode());

            byte[] bytes = Encoding.UTF8.GetBytes(encoding);

            switch (alg)
            {
            case JWTAlgorithm.HS256:
            case JWTAlgorithm.RS256:
                return(signingCredentials.SignData(bytes));

            default:
                throw new InvalidOperationException();
            }
        }