Exemple #1
0
        public void RSATest()
        {
            Dictionary <string, string> testValues = new Dictionary <string, string>
            {
                { "tENV2V1qazRhfL2V", "43f3587ea7dd5c19848c6aa704d9b81f01312b978d1501e5d6a5b59fa575fc95af7a96705f987e690d6e43e0ca2a657e31993bacb093ed30295fc04be6c6bff26b37e8d0aa46c47cd0cf91c0b826a4c3da5d4a761366658bd7f94a1f9ee070d6e536c68b019d796ad6876ce96bbaf3657034f02a1e54129bfeadf8de12642aa3" },
                { "Odcsdlcx4tK2kbkZ", "debc4f2b175f7cf0340edad68315a2b15ce6eca4642a40c6e4d9b66d025676bb78aa66278cafca138a1ae56f6f63d75933d9fb1340baff41d87287f40f66f5da3161e9d0aa062cc6a5d5c4ab97a86c854ef2ca63204a9dea6d01baf6d987fe675873b9ebda727869fe85a25fd06b273c7f87dbf134165a181b2480e2ab244741" },
                { "Bwkj1LLNk5GE83KW", "196e553c2d6752e51729311131ec82ceea94a272742b0721f02c1b0ef0b63acbabb33df8cad72024da387ccf92c065faa5fa54d91f2e06e71c8948b40f000443e3f4bb9e7733448a3d5040f65b5ed8a790a8e8dda8ecccde39a744eac8cb22c1d56df98481dd675ddff345118a7a16568a840b09b0aeb57f18d6ac85daab7993" },
                { "yLWqByPTdohGYGkV", "c3a7d879cc01e60dbf645800dd79152fa32e960d51a13be6a381191c4ff3e0ceaf481ae60cd92c7b5ff1750c88a8e113953716ff49322897c100f9662efee3c5e3de3566948c6caee3b0a8ddacc6ec68d406d3d3824853467e5a06953f9b418007350a270583580999d6b3ae6643fad1f4eeeb62fade19db6aa3fe8faa17a874" },
                { "CmFXKvmhoELzu892", "c53c7fba6d297a63fdd5f6fc7f1236afa09d54903717a88c3c6276f7897d5d5a26643b1b90621fbf2f423ac9d3809972e40f67c27c58b160cb936648af671ec1f3ffe1b7f15932fece365ee084a47c5aedbc0abfc8ceb4c2190d4669573b7c57447e415cc49ff732a750c313596f4df54e02afeb3c9d2d5f3862fdd484883c58" },
                { "q5BhbiN9PdHmwlRM", "9ac030f35abfb70a5524d9e5cae0ef3cf04145e83a9cf54c35a1f38b2cab2f3f562af385974adbf7d8f819abc86d5f7753958861c959cfae58e29ce5230c48a1e3da6db3500d1e0c567326c00f02d27c77b5698f0542d8efeda69a4fc2e6bcca830171519fc8acd395d4b19b49dcd990ce21297b9ca3ad92d64fa86e87a3e05e" },
                { "DXviAvflnoGfMhFr", "9b3a15615f9b1ec40469c3aea145535ad1abacc0c5918dae1dead0ef6e5de7a93530071442f44c7584a1f5418f645ed8bf444dbd93cc813cec6122e5cc5b6d863c8a67503762ffd9979e86e4783d26363072536173239264c7abfe4daf75e4832ab9d28e52b5e6fb2306bd7760a64de06be72613bf58fdd481b53f777380c8c6" },
                { "kfc2Ho5DOggKlsB3", "0a7135f60d4154dda3b35d89d9f960d55c3afec54c36440014c286c4827619ef681e8a372f8167a65d0f9e3acde975b1f8cdf260668e7d8920b96f0845c1b9698952281c69c3e5cc7e02bea3c3fd22ddcd142535c6889fefe66b87121f24ec8a3bc532bf864460c426dfee695987a28a252708bc89c2aefb46a0ccd30bf31a3e" },
                { "i86jIMm9dhy5r6HD", "5287992f61e6510d4b5cca02710f33910d2daed44abd554c4414893474234d0da950ac37aaac8b5bf7aa0d0777903fa8ff12dbe9840b781100ef4f81fc751770119ffa48a5588f7d0532f0a291cae57a60ca7cf3de7eb3402ce258b74d8a6ab2ed7a1078b4735c75dcc43ce9d3fe54f4579a58d87dec1ab43c00852417d37854" },
                { "zZPG6TWokLiWDzHb", "2ad824139161f33dd35a424f133988ba6f05b74d2ff8cc2eb654ea8fe20aa408046bb13fb672174ab264520fc2582480f163ed83fba143b972fef0d3d98159c72fcede785de0c8d6885647a638e15513293afdd025a44989c98cfa5b4fa4041da9298c1fe5d35ed1b0471d857111cd8beb341ca187d13bf21c105023fc8ce0d9" },
                { "MIuZI74e7YJUgy3r", "6437513d03b418ceadcaf6f25f87d88ab5e228b45536bf46b98f2355376bed1bc792c3b2e36496035da1fb7a8ffc44cd87038a97e546445c1e6ce76b9e616f354301c958d7cb4ed65c34cea6f03f97c06d2ef57b65ba7fd3afee3316b5b41e3560f8a93cfb9539ccecd536137226eb025eb8c528e684133eed2c1787e5dd26bf" },
                { "RgEfsGFMKgnWqvu8", "d64c7fd7c7a9aff8a8047512e8a3ce32ef6cf58954d8f1634ced6e8ce66efcbcf88cec146e3a084219946b2a0b30c9cb4efaac7eb0da0f8f2d0a37e54e35d9266d94cfd2f7c19828e5b29722e7d2b3993f70862ac427c5659a1673e99888f1a83febb5f17bb08eb3451febfe1bdd07a5fc714cb29bcff9685752f0eed8274a31" },
                { "135y3FoyCnlRGzTl", "9eabd078ac706b3a754e46433e25d49dad8f4c0013a3af8bb3615aebfe13b2d9f129d5c0c5a69f1f15082fa78eb98bb0249c05dc90d78155b764459b818ef11838477be308e858ba7463a6733f75d6e7ce452c1d94094771a6362e22530482850fcdd4dd2eb4f77666469c52fd563708a7f0c43b38c2baa00be2bc453d80c591" },
                { "dZrL9r0W5Yj9yB7l", "417320a03fba100122f0440d42fe829b506ebec363ca0e5ce651ed63d9f444451bc0e0a89cb395b624e17509b623b614244942a295e5e17af384c44e5a35c57b19bdb0391a743c38eb25b9fc630a5fc5fd61bfd4aad3292a9024e6209da1570e352288d49c83f5ee214d0d2406d301563eda574f8ef6cd67860fd882f6936aae" },
                { "iNXTrX3qLAjCNhal", "2255a4a142c6cd8c0fc9a309ebf76060b34396a22d6083771e5fe5409eba421bf3f1eec013c7ac7c3d1134cb8aee4b1fa94b1335f9b80e835e0bc70ddd6961c403f2cc7c2b50d0f7f55f43573963542ee9ff6560744fe19cd03fb6064906d8f5d5adda62a4e6019918919314230e3fccbd7f22b752df64cec3873ba104fbc90c" },
                { "9Y0XCBNo1qeIZ8Pl", "450b1d2f750a60c0ebb6e1d3b2a821dcb1b8b6e01b7a85a4adf9282faa410d4b2c716039ea9ea0322bb46450dab0c73724ca4d452ce34f5b5be6d5bf16c521557c37a1368efc97bd7fc37f15d482c251f095c5d154f5602449ad1e3ed3bff6fd42d52e9b9a847fbfb2f1ff148464b4ec67b8adc5638fb058a7c720a909193f70" },
            };

            //src:
            //result:
            foreach (var testValue in testValues)
            {
                string result = RSAHelper.EncryptByPublicKey(testValue.Key, Modulus, PubKey);
                Assert.AreEqual(testValue.Value, result);
            }
        }
        public string SendData(string uri, string content, string key = null)
        {
            var encrypted = EncrpytAes(content, AesKey1);

            key       = key ?? RandomKey();
            encrypted = EncrpytAes(encrypted, key);
            var encryptedKey = RSAHelper.EncryptByPublicKey(key, Modulus, PubKey);
            var form         = new FormUrlEncodedContent(new Dictionary <string, string>
            {
                { "params", encrypted },
                { "encSecKey", encryptedKey },
            });

            return(HttpPost(uri, form));
        }