public UniRx.IObservable <Sas.Net.HTTPResult> SignUp(AccountSignupParam param)
            {
                return(Observable.Range(0, 1)
                       .SelectMany(_ => {
                    var req = new AccountSignUpReqParam();
                    using (var aes = new System.Security.Cryptography.AesManaged()) {
                        using (var iv = SecureHelper.APP_IV) {
                            aes.IV = iv.GetByte(Convert.FromBase64String);
                        }

                        using (var key = SecureHelper.APP_KEY) {
                            aes.Key = key.GetByte(Convert.FromBase64String);
                        }

                        req.authentication = authentication;
                        req.token = param.password.GetByte(aes.Encrypt);
                        req.email = param.email.GetByte(aes.Encrypt);
                        using (var rsa = new System.Security.Cryptography.RSACryptoServiceProvider()) {
                            req.public_key = aes.Encrypt(rsa.ToXmlString(false));
                            req.private_key = rsa.ExportPrivateKey().GetByte(aes.Encrypt);
                            req.test = param.email.GetByte(rsa.Encrypt);
                        }
                    }

                    var json = JObject.FromObject(req);
                    return context.Post("/Account/SignUp", json);
                }));
            }
Exemple #2
0
        /// <summary>
        /// Returns a binary array of encrypted data for the given parameters.
        /// </summary>
        /// <param name="source">Binary array of data to encrypt.</param>
        /// <param name="startIndex">Offset into <paramref name="source"/> buffer.</param>
        /// <param name="length">Number of bytes in <paramref name="source"/> buffer to encrypt starting from <paramref name="startIndex"/> offset.</param>
        /// <param name="key">Encryption key to use to encrypt data.</param>
        /// <param name="iv">Initialization vector to use to encrypt data.</param>
        /// <param name="strength">Cryptographic strength to use when encrypting data.</param>
        /// <returns>An encrypted version of the source data.</returns>
        public static byte[] Encrypt(this byte[] source, int startIndex, int length, byte[] key, byte[] iv, CipherStrength strength)
        {
            if (strength == CipherStrength.None)
                return source;

            AesManaged symmetricAlgorithm = new AesManaged();

            symmetricAlgorithm.KeySize = (int)strength;

            return symmetricAlgorithm.Encrypt(source, startIndex, length, key, iv);
        }