示例#1
0
    void OnGUI()
    {
        isGeneratePublicKey = EditorGUILayout.Foldout(isGeneratePublicKey, "Generate Public Key");
        if (isGeneratePublicKey)
        {
            EditorGUILayout.LabelField("Base64 Encoded Key");
            base64EncodedKey = EditorGUILayout.TextField(base64EncodedKey);
            EditorGUILayout.LabelField("Public Key");
            publicKey = EditorGUILayout.TextArea(publicKey);
            if (GUILayout.Button("Generate Public Key"))
            {
                if (string.IsNullOrEmpty(base64EncodedKey))
                {
                    return;
                }
                publicKey = PEMKeyLoader.CryptoServiceProviderFromPublicKeyInfo(Convert.FromBase64String(base64EncodedKey)).ToXmlString(false);
            }
        }

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Documentation", GUILayout.MaxWidth(100), GUILayout.MinHeight(20)))
        {
            Application.OpenURL("https://docs.google.com/document/d/1CJzaeXxBSbbVvzWRXmxOLpcz79yCvDlYIZPfoAshap8/pub?embedded=true");
        }

        if (GUILayout.Button("Demo APK", GUILayout.MaxWidth(100), GUILayout.MinHeight(20)))
        {
            Application.OpenURL("https://drive.google.com/open?id=0B-frjQ_v6A5tWDNVc0UyTTdiZ3M");
        }

        EditorGUILayout.EndHorizontal();
    }
示例#2
0
        public static bool VerifySignature(string encodedPublicKey, string base64Signature, string payload)
        {
            RSACryptoServiceProvider provider = PEMKeyLoader.CryptoServiceProviderFromPublicKeyInfo(encodedPublicKey);

            // The signature is supposed to be encoded in base64 and the SHA1 checksum
            // of the message is computed against the UTF-8 representation of the message
            byte[]      signature = System.Convert.FromBase64String(base64Signature);
            SHA1Managed sha       = new SHA1Managed();

            byte[] data = System.Text.Encoding.UTF8.GetBytes(payload);

            return(provider.VerifyData(data, sha, signature));
        }
示例#3
0
 // Token: 0x06000E9E RID: 3742 RVA: 0x0005D928 File Offset: 0x0005BB28
 private static bool VerifyMessage(string appId, string appKey, string message, string signature)
 {
     try
     {
         RSACryptoServiceProvider rsacryptoServiceProvider = PEMKeyLoader.CryptoServiceProviderFromPublicKeyInfo(appKey);
         byte[]      signature2 = Convert.FromBase64String(signature);
         SHA1Managed halg       = new SHA1Managed();
         byte[]      bytes      = Encoding.UTF8.GetBytes(appId + "\n" + message);
         return(rsacryptoServiceProvider.VerifyData(bytes, halg, signature2));
     }
     catch (Exception ex)
     {
         Logger.Log(ex.ToString());
     }
     return(false);
 }