• <bdo id='dOYhY'></bdo><ul id='dOYhY'></ul>

  • <tfoot id='dOYhY'></tfoot>

      <i id='dOYhY'><tr id='dOYhY'><dt id='dOYhY'><q id='dOYhY'><span id='dOYhY'><b id='dOYhY'><form id='dOYhY'><ins id='dOYhY'></ins><ul id='dOYhY'></ul><sub id='dOYhY'></sub></form><legend id='dOYhY'></legend><bdo id='dOYhY'><pre id='dOYhY'><center id='dOYhY'></center></pre></bdo></b><th id='dOYhY'></th></span></q></dt></tr></i><div id='dOYhY'><tfoot id='dOYhY'></tfoot><dl id='dOYhY'><fieldset id='dOYhY'></fieldset></dl></div>

      <small id='dOYhY'></small><noframes id='dOYhY'>

      1. <legend id='dOYhY'><style id='dOYhY'><dir id='dOYhY'><q id='dOYhY'></q></dir></style></legend>

        点网中的Android应用内计费验证收据(C#)

        时间:2023-06-02
      2. <small id='ely8n'></small><noframes id='ely8n'>

        <legend id='ely8n'><style id='ely8n'><dir id='ely8n'><q id='ely8n'></q></dir></style></legend><tfoot id='ely8n'></tfoot>

        <i id='ely8n'><tr id='ely8n'><dt id='ely8n'><q id='ely8n'><span id='ely8n'><b id='ely8n'><form id='ely8n'><ins id='ely8n'></ins><ul id='ely8n'></ul><sub id='ely8n'></sub></form><legend id='ely8n'></legend><bdo id='ely8n'><pre id='ely8n'><center id='ely8n'></center></pre></bdo></b><th id='ely8n'></th></span></q></dt></tr></i><div id='ely8n'><tfoot id='ely8n'></tfoot><dl id='ely8n'><fieldset id='ely8n'></fieldset></dl></div>
            <tbody id='ely8n'></tbody>
              <bdo id='ely8n'></bdo><ul id='ely8n'></ul>

                • 本文介绍了点网中的Android应用内计费验证收据(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个提供应用内计费的 Android 应用程序,我们有我们的应用程序服务器,android 应用程序连接到该应用程序服务器以向用户提供服务,在应用程序内购买时,我们希望将收据推送到服务器以进行验证过程.

                  I have a Android application which provides in-app billing and we have our application server to which android application connects to provide services to the user, on in-app purchase we want to push receipt to the server for verification process.

                  现在的问题是我不知道如何转换 Security.java 文件在 dot net(C#) 中,因为我们的服务器是用 dot net 编写的

                  Now problem is I don't know how to convert Security.java file in dot net(C#) as our server is written in dot net

                  注意:此文件与提供消息签名功能的 android 应用内计费相同的应用程序一起提供,我只需要它们在 dot net 中的等价物.

                  NOTE: This file comes with android in-app billing same application which provides message signing functions i just need their equivalent in dot net.

                  有关此问题的更多详细信息,请访问http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/66bb5683-fde6-47ca-92d7-de255cc8655a

                  More Detail regarding this problem is available at http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/66bb5683-fde6-47ca-92d7-de255cc8655a

                  推荐答案

                  我找到了解决方案,要实现你首先必须转换公钥格式,因为 dot net 使用排序不同的 Key 作为输入.

                  I found the solution, to achieve you first have to convert the public key format as dot net uses sort of different Key as an input.

                  我不知道其他方法,但我们可以使用 java 代码获取点网格式密钥,您只需运行一次即可生成点网友好的 RSA 公钥.(仅在给定公众没有快速变化时才建议这样做,例如在 Android 市场应用内计费的情况下)

                  I don't know the other ways but we can get dot net format key using a java Code which you have to run only once to generate the dot net friendly RSA Public Key. (this is only recommended when the given public do not changes rapidly e.g. in case of Android market in-app billing)

                  以下 Java 代码对我有用

                  following Java Code worked for me

                  public static DotNetRSA GenerateDotNetKey(String base64PubKey)
                              throws IOException, NoSuchAlgorithmException,
                              InvalidKeySpecException {
                          /*
                           * String base64PubKey - 
                           * Is a Key retrieved from Google Checkout Merchant Account
                           */
                          BASE64Decoder decoder = new BASE64Decoder();
                  
                          byte[] publicKeyBytes = decoder.decodeBuffer(base64PubKey);
                  
                          EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(publicKeyBytes);
                          RSAPublicKey publicKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(publicKeySpec);
                  
                          byte[] modulusBytes = publicKey.getModulus().toByteArray();
                          byte[] exponentBytes = publicKey.getPublicExponent().toByteArray();
                  
                          modulusBytes = stripLeadingZeros(modulusBytes);
                  
                          BASE64Encoder encoder = new BASE64Encoder();
                          String modulusB64 = encoder.encode(modulusBytes);
                          String exponentB64 = encoder.encode(exponentBytes);
                  
                          return new DotNetRSA(modulusB64, exponentB64);
                      }
                  
                        private static byte[] stripLeadingZeros(byte[] a) {
                          int lastZero = -1;
                          for (int i = 0; i < a.length; i++) {
                            if (a[i] == 0) {
                              lastZero = i;
                            }
                            else {
                              break;
                            }
                          }
                          lastZero++;
                          byte[] result = new byte[a.length - lastZero];
                          System.arraycopy(a, lastZero, result, 0, result.length);
                          return result;
                        }
                  

                  现在要验证数字签名,您可以在您的点网程序(c#)中使用以下代码,前提是 GCHO_PUB_KEY_EXP 是您的指数,GCHO_PUB_KEY_MOD 是您通过上述 Java 代码提取的模数

                  Now to verify the Digital Signature you can use the following code in your dot net program(c#) provided GCHO_PUB_KEY_EXP is your Exponent and GCHO_PUB_KEY_MOD is your Modulus extracted by above Java Code

                  public static bool VerifyDataSingature(string data, string sign)
                  {
                       using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
                       {
                           RSAParameters rsaKeyInfo = new RSAParameters() 
                           { 
                               Exponent = Convert.FromBase64String(GCHO_PUB_KEY_EXP), 
                               Modulus = Convert.FromBase64String(GCHO_PUB_KEY_MOD) 
                           };
                           rsa.ImportParameters(rsaKeyInfo);
                  
                           return rsa.VerifyData(Encoding.ASCII.GetBytes(data), 
                                                 "SHA1", 
                                                 Convert.FromBase64String(sign));
                       }
                  }
                  

                  我希望它对每个人都适用,就像对我一样.谢谢

                  I hope it will work for everyone as worked for me. Thanks

                  归功于 Code Project Artical

                  这篇关于点网中的Android应用内计费验证收据(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:AES 加密和 C# 下一篇:在 C# 中生成随机盐的最佳方法?

                  相关文章

                  最新文章

                • <i id='oH6GZ'><tr id='oH6GZ'><dt id='oH6GZ'><q id='oH6GZ'><span id='oH6GZ'><b id='oH6GZ'><form id='oH6GZ'><ins id='oH6GZ'></ins><ul id='oH6GZ'></ul><sub id='oH6GZ'></sub></form><legend id='oH6GZ'></legend><bdo id='oH6GZ'><pre id='oH6GZ'><center id='oH6GZ'></center></pre></bdo></b><th id='oH6GZ'></th></span></q></dt></tr></i><div id='oH6GZ'><tfoot id='oH6GZ'></tfoot><dl id='oH6GZ'><fieldset id='oH6GZ'></fieldset></dl></div>

                  <small id='oH6GZ'></small><noframes id='oH6GZ'>

                  <tfoot id='oH6GZ'></tfoot>

                      • <bdo id='oH6GZ'></bdo><ul id='oH6GZ'></ul>

                      <legend id='oH6GZ'><style id='oH6GZ'><dir id='oH6GZ'><q id='oH6GZ'></q></dir></style></legend>