Exemple #1
0
        public static bool KeysAreCompatible(byte[] publicKey, byte[] privateKey)
        {
            if (publicKey == null || privateKey == null)
            {
                return(false);
            }

            MixCastEncrypter encrypter = new MixCastEncrypter(publicKey);
            MixCastDecrypter decrypter = new MixCastDecrypter(privateKey);

            byte[] testData  = { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9 };
            byte[] encrypted = encrypter.Encrypt(testData);
            byte[] decrypted = decrypter.Decrypt(encrypted);

            if (!MixCastCryptoUtils.BytesEqual(testData, decrypted))
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        private static MixCastData.SecureData ReadSecureSettingsFromRegistry(RegistryKey reg)
        {
            InitDecrypt();

            if (_Decrypt == null)
            {
                return(null);
            }

            string encryptedDataStr = reg.GetValue(SECURE_REGISTRY_KEY, null) as string;

            if (string.IsNullOrEmpty(encryptedDataStr))
            {
                Debug.LogWarning("no secure settings data found");
                return(null);
            }

            byte[] encryptedData = Convert.FromBase64String(encryptedDataStr);
            byte[] decryptedData = _Decrypt.Decrypt(encryptedData);
            var    dataStr       = Encoding.UTF8.GetString(decryptedData);

            return(string.IsNullOrEmpty(dataStr) ? null : JsonUtility.FromJson <MixCastData.SecureData>(dataStr));
        }