public static async Task SetSaltAsync(byte[] salt)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string> {
                { "Salt", System.Convert.ToBase64String(salt) }
            };
            FormUrlEncodedContent encodedContent = new FormUrlEncodedContent(parameters);

            using (HttpResponseMessage response = await EncryptionController.SetSalt(encodedContent))
            {
                int    status = (int)response.StatusCode;
                string body   = await response.Content.ReadAsStringAsync();

                if (status == 200)
                {
                    return;
                }
                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("An uncaught error occurred.");
                }
            }
        }
        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");
            }
        }
    public void MD5()
    {
        string hashMe     = "The definition of a perfectionist: someone who wants to go from point A to point A+. —David Bez";
        string hashedStr  = EncryptionController.ConvertToMd5(hashMe);
        string hashedStr2 = EncryptionController.ConvertToMd5(hashMe);


        Assert.AreNotEqual(hashMe, hashedStr);
        Assert.AreEqual(hashedStr, hashedStr2);
    }
Exemple #4
0
    static EncryptionController()
    {
        Instance = new EncryptionController();

        var cc = CoflnetCore.CoreCommands;

        cc.RegisterCommand(new LegacyCommand("sessionSetup", Instance.ReceiveSessionSetup));
        cc.RegisterCommand(new LegacyCommand("resendSetup", Instance.RequestResendSetup));
        cc.RegisterCommand <ReceivedSetup> ();
    }
    private void SaveBestScoreAndEditLevelCompletedPanel(string selectedGameMode)
    {
        levelCompletedScoreText.text = currentScore.ToString();
        int bestScore;

        if (selectedGameMode == "Zamana Karşı")
        {
            bestScore = int.Parse(EncryptionController.Decrypt(PlayerPrefs.GetString("bestScoreOfAgainstTime")));
        }
        else
        {
            bestScore = int.Parse(EncryptionController.Decrypt(PlayerPrefs.GetString("bestScoreOfNormal")));
        }
        if (currentScore > bestScore)
        {
            recordOldAreaForLevelCompletedArea.SetActive(false);
            recordNewAreaForLevelCompletedArea.SetActive(true);
            if (selectedGameMode == "Zamana Karşı")
            {
                PlayerPrefs.SetString("bestScoreOfAgainstTime", EncryptionController.Encrypt(currentScore.ToString()));
                if (EncryptionController.Decrypt(PlayerPrefs.GetString("removeAdsPurchased")) == "No")
                {
                    StartCoroutine(AdsAdMobController.InstanceAdsAdMobController.LoadInterstitialAd());
                } // Show InterstitialAd
                PlayServicesController.AddScoreToLeaderboard(GPGSIds.leaderboard_lider_tablosu__zamana_kar, currentScore);
            }
            else
            {
                PlayerPrefs.SetString("bestScoreOfNormal", EncryptionController.Encrypt(currentScore.ToString()));
                if (EncryptionController.Decrypt(PlayerPrefs.GetString("removeAdsPurchased")) == "No")
                {
                    StartCoroutine(AdsAdMobController.InstanceAdsAdMobController.LoadInterstitialAd());
                } // Show InterstitialAd
                PlayServicesController.AddScoreToLeaderboard(GPGSIds.leaderboard_lider_tablosu__normal_mod, currentScore);
            }
        }
        else
        {
            recordOldAreaForLevelCompletedArea.SetActive(true);
            recordNewAreaForLevelCompletedArea.SetActive(false);
            recordOldAreaForLevelCompletedArea.GetComponent <Text>().text = "Rekorunuz : " + bestScore.ToString();
        }
    }
Exemple #6
0
        public MainForm()
        {
            InitializeComponent();

            controller = new EncryptionController();
        }
 public UserModel(string email, string password, bool passwordNeedsHashing)
 {
     this.Email    = email;
     this.Password = passwordNeedsHashing ? EncryptionController.ConvertToMd5(password) : password;
 }