【问题标题】:The method Encrypt(long, long, long, long, int) in the type prince is not applicable for the arguments (String, long, long, long, int)Prince 类型中的 Encrypt(long, long, long, long, int) 方法不适用于参数 (String, long, long, long, int)
【发布时间】:2014-11-10 03:46:47
【问题描述】:

虽然我已使用不同的方法将数据类型更改为字节,但我无法找出为什么“加密”函数仍将“消息”读取为字符串。

错误信息是“Prince 类型中的方法 Encrypt(long, long, long, long, int) 不适用于参数 (String, long, long, long, int)”。

btnSendSMS.setOnClickListener(new View.OnClickListener() 
        {
            public void onClick(View v, String args) 
            {             
             String phoneNo = txtPhoneNo.getText().toString();
             String message = txtMessage.getText().toString();              
                if (phoneNo.length()>0 && message.length()>0){
                    //prince pri = new prince();
                    //message = toLong();
                    //byte[] data = message.getBytes("UTF-8");
                    //LongBuffer messageToLongBuffer;

                    //String str = message;
                    //byte[] array = str.getBytes();
                    String str = message;
                    byte[] bytes = message.getBytes();
                    prince.Encrypt (message, k0, kop, k1, t);

                    //maybe check to decrypt the ciphertext here
                    //prince.decrypt(message)
                    //sendSMS explore the sendDataMessage
                    sendSMS(phoneNo, message); }               
                else
                 Toast.makeText(getBaseContext(), 
                        "Please enter both phone number and message.", 
                        Toast.LENGTH_SHORT).show();
            }

【问题讨论】:

  • byte[] 也不是 long
  • 很抱歉,但正如我的讲师告诉我的那样,字节可以读取任意长,所以你是说它不一样? @SLaks

标签: java android type-conversion


【解决方案1】:

我不知道为什么“加密”功能仍将“消息”读取为 字符串虽然我已将数据类型更改为不同的字节 方法。

大声笑,更改您的代码:

 byte[] bytes = message.getBytes();
 prince.Encrypt (bytes, k0, kop, k1, t); //HEREEEEEEEEEEEEE :)

【讨论】:

    【解决方案2】:

    从字符串的值创建一个新的byte[] 变量不会神奇地将现有变量更改为byte[] 类型。

    其实没有办法改变变量的类型。
    如果你想传递byte[],传递byte[]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-29
      • 1970-01-01
      • 2018-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-12
      相关资源
      最近更新 更多