Esempio n. 1
0
        internal static byte[] EncryptJoinKey(JoinKey playerToken)
        {
            var serialized = JsonConvert.SerializeObject(playerToken);
            var encrypted  = PlayerIOEncrypt.Encrypt(serialized.ToBytes());

            return(encrypted);
        }
Esempio n. 2
0
        private static byte[] EncryptPlayerToken(PlayerToken playerToken)
        {
            var serialized = JsonConvert.SerializeObject(playerToken);
            var encrypted  = PlayerIOEncrypt.Encrypt(serialized.ToBytes());

            return(encrypted);
        }
Esempio n. 3
0
        internal static JoinKey DecryptJoinKey(byte[] joinKey, bool maskedToken = false)
        {
            var decrypted = PlayerIOEncrypt.Decrypt(joinKey);

            if (decrypted == null || decrypted.Length < 1)
            {
                return(null);
            }

            return(JsonConvert.DeserializeObject <JoinKey>(decrypted.FromBytes()));
        }
Esempio n. 4
0
        private static PlayerToken DecryptPlayerToken(byte[] playerToken, bool maskedToken = false)
        {
            if (!PlayerIOEncrypt.Authenticate(playerToken))
            {
                return new PlayerToken()
                       {
                           Invalid = true
                       }
            }
            ;

            var decrypted    = PlayerIOEncrypt.Decrypt(playerToken).FromBytes();
            var deserialized = JsonConvert.DeserializeObject <PlayerToken>(decrypted);

            return(deserialized);
        }
    }