类型为prince的方法Encrypt(long,long,long,long,int)不适用于参数(String,long,long,long,int)

时间:2014-11-10 03:46:47

标签: java android type-conversion

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

错误消息“类型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();
            }

2 个答案:

答案 0 :(得分:1)

  

我无法找出为什么“加密”功能仍然将“消息”视为   尽管我已经将数据类型更改为具有不同的字节   方法

LOL,更改您的代码:

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

答案 1 :(得分:0)

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

实际上,没有办法改变变量的类型 如果您想传递byte[],请传递byte[]