Beispiel #1
0
        public static async Task <byte[]> GetSaltAsync()
        {
            int    status;
            string body;

            using (HttpResponseMessage response = await EncryptionController.GetSalt())
            {
                status = (int)response.StatusCode;
                body   = await response.Content.ReadAsStringAsync();
            }

            if (status == 200)
            {
                return(System.Convert.FromBase64String(body));
            }
            else if (status == 400)
            {
                throw new Exception(body);
            }
            else if (status == 401)
            {
                throw new UnauthenticatedException();
            }
            else if (status == 500)
            {
                throw new ServerException();
            }
            else
            {
                throw new Exception("Uncaught status code");
            }
        }