public void EncodeHS512() { //given string payload = @"{""hello"": ""world""}"; //when string test = Jwt.Encode(payload, JwsAlgorithms.HS512, shaKey); Debug.WriteLine("HS512 = {0}", test); //then Assert.AreEqual("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJoZWxsbyI6ICJ3b3JsZCJ9._1m5AmI1xbSfVpykAm9PMXYuQLIdqWuRN8Lz6hFMDq0beqLAaH4Dh2VQNlXzoBG7Nk4vHx2gZgVuhF62cnXcKQ", test); }
public void EncodePlaintext() { //given string payload = @"{""hello"" : ""world""}"; //when string test = Jwt.Encode(payload, JwsAlgorithms.None, null); Debug.WriteLine("test = {0}", test); //then Assert.AreEqual("eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJoZWxsbyIgOiAid29ybGQifQ.", test); }
public void EncodeHS384() { //given string payload = @"{""hello"": ""world""}"; //when string test = Jwt.Encode(payload, JwsAlgorithms.HS384, shaKey); Debug.WriteLine("HS384 = {0}", test); //then Assert.AreEqual("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzM4NCJ9.eyJoZWxsbyI6ICJ3b3JsZCJ9.Be1KYCRGFbv0uQwelaRj0a5SYDdbk_sYsXkfrbRI6TmYpuWBga_RsiU2TyyyjoXR", test); }
public void EncodeHS256() { //given string payload = @"{""hello"": ""world""}"; //when string test = Jwt.Encode(payload, JwsAlgorithms.HS256, shaKey); Debug.WriteLine("HS256 = {0}", test); //then Assert.AreEqual("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJoZWxsbyI6ICJ3b3JsZCJ9.KmLWPfxC3JGopWImDgYg9IUpgAi8gwimviUfr6eJyFI", test); }
public void EncodeRS512() { //given string json = @"{""hello"": ""world""}"; //when string test = Jwt.Encode(json, JwsAlgorithms.RS512, PrivateKey.Load(privateKey)); //then Debug.WriteLine("RS512 = {0}", test); Assert.AreEqual(test, "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzUxMiJ9.eyJoZWxsbyI6ICJ3b3JsZCJ9.YJ_5bDkZUgZj1ZoyTbSeYerUnahjt4Llbj6IwUQUY-zH_mMpywJHs2IT8wteUyX32lCCGr4NfNKpkC-zMMq7aDsklSKIg8sdGYDMheGsEw9YD0QRBF1Ovt4yuSZjWsgmdGSapXKc8CBqSzPCr9S1Rns8YhVHAYMfzHrahXuroYK35gVPQKKLbYQGcwnhpgvxMx0EfGyFbSc6r6XYK-fJ5lSqBh4wSxVMBy_5CkTVWpmnDjRuycE_j4c-yuTYUEAsj5o0sW2ahPf8aomBUC5I1ZG2yTAz8BX7dud6s2VPJQRRsUKlMNrUcMGEooJMoL_vmek9z3t_z9KFyyVHuY5XUA"); Assert.AreEqual(Jwt.Decode(test, PublicKey.Load(publicKey)), json); }
public void EncodeRS384() { //given string json = @"{""hello"": ""world""}"; //when string test = Jwt.Encode(json, JwsAlgorithms.RS384, PrivateKey.Load(privateKey)); //then Debug.WriteLine("RS384 = {0}", test); Assert.AreEqual(test, "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzM4NCJ9.eyJoZWxsbyI6ICJ3b3JsZCJ9.Tsq02ZIAOOK8ck0NS7VJ2NOmL6VpATGTb5hVUQC9_DJqiyrp2Vs8KGw9ahRjvIQMElkcFuWRPg-MGgHd7XUPVbhm7jK3cBvQ4y9hal6VNFfsL_DWhijLYgFpBj2nEw_qqZbChrPNRn-B1BrMKuRHOqu-7D3PPPMv9hvSg80WOLlkOUgIhp3a64saPJ8rDEibowdNNXw0k0H2i1D6WLK59Ew-6v6qO8OI9bkVc7SDV9qZSx3n0hm_JfyZbkCb-KKacJnkfVcnlNIRXRbk7cdlp90uYJ1aJDZrcIVTUOOAHQCQ4uaGwxhmH_NNHiY-sjWybP7xQCSq-Ip0yNVstWfUTQ"); Assert.AreEqual(Jwt.Decode(test, PublicKey.Load(publicKey)), json); }
public void EncodeRS256() { //given string json = @"{""hello"": ""world""}"; //when string test = Jwt.Encode(json, JwsAlgorithms.RS256, PrivateKey.Load(privateKey)); //then Debug.WriteLine("RS256 = {0}", test); Assert.AreEqual(test, "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJoZWxsbyI6ICJ3b3JsZCJ9.M3uJ9g4_e_lCyd0LtSJuSPMHe_s0Bj6LDA2kqf041SA3Les8aUmRQGlkG3ng63Thw6q06hF6r5bXX8tamku8AOyc45TIfPY9caNKKcVJ6RtXBxRWSY3r3Uh9o5zg3EOElfMWuekz0jfVfOaRgMO358ARsKW5BY6jfgmKsVyG1n3uYm8ESpzPlWWLcgUEjUSq3_m5t-COKySXa_zPPtFnA__159kSKCQRm4OcbYWzJD3-xl2i2GRQFLP7npLAuGPv42t5zf8snJvBWbROsdvvs7qzZ5v6bJy8wuBe9mGXmnbRsMFCzooZQ4H8LFrSnT3DakPVdLcDWE5HxZ-Ikr9l0A"); Assert.AreEqual(Jwt.Decode(test, PublicKey.Load(publicKey)), json); }