-1

向 stackoverflow 的所有成员致敬。

我是 Android 开发新手,谁能告诉我如何在网站上发布数据或给我一个采样器?

我想将哈希发布到在线破解者并将结果作为字符串返回。

edit_box = enter the hash

sendbutton = 发送哈希 text_view = 结果

http://xdecrypt.com/# 谢谢

编辑:我看一下@ Live headers,发现这个结果 http://xdecrypt.com/ajax/liste.php?hash=759fdfa1a99563aa6309bb6ae27537c564547f62

在这里,我们可以将哈希添加到 Url,结果是。

document.getElementById('hashresult').value="";document.getElementById('hashresult').value+="759fdfa1a99563aa6309bb6ae27537c564547f62(MySQL)=amande1975 ";

现在我想把它读成字符串有人可以帮忙吗?

我想显示 Hashtype MySQL 和密码 amande1975。并在 ui 上显示为 text_view。

再次感谢。

编辑:2 它的作品,但现在如何分割字符串?有人可以帮忙吗?

          try {
            String webPage = "http://xdecrypt.com/ajax/liste.php?hash="+hashedit.getText().toString();
            URL url = new URL(webPage);
            URLConnection urlConnection = url.openConnection();
            InputStream is = urlConnection.getInputStream();
            InputStreamReader isr = new InputStreamReader(is);

            int numCharsRead;
            char[] charArray = new char[1024];
            StringBuffer sb = new StringBuffer();
            while ((numCharsRead = isr.read(charArray)) > 0) {
                sb.append(charArray, 0, numCharsRead);
            }
            String result = sb.toString();

            System.out.println("*** BEGIN ***");
            System.out.println(result);
            System.out.println("*** END ***");

            TextView tv2 = (TextView) findViewById(R.id.textView2);
            tv2.setText("HashResuld="+sb.toString());

EDIT3:它的作品;)

再次感谢没有帮助;)

4

1 回答 1

0

我之前做过一些研究,并且 ksoap2 能够使用 web 服务 url 进行数据传输,我相信它还有其他可以使用的 http 功能。

http://ksoap2.sourceforge.net/

下载 ksoap2 并导入您的项目并创建您的服务访问层,如下所示:

import java.util.ArrayList;
import java.util.List;

import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;

import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.ksoap2.SoapEnvelope;


public class ServiceAccess {

private static String Namespace;
private static String MethodName;
private static String URL;
private SoapSerializationEnvelope Envelope;
private SoapObject SoapRequest;
private SoapPrimitive Response;
private List<PropertyInfo> methodParamList; 

public ServiceAccess(String webserviceUrl, String methodName) throws Exception
{
    setUrl(webserviceUrl);
    setMethodName(methodName);
    setNamespace("http://tempuri.org/");
    SoapRequest = new SoapObject(this.getNamespace(), this.getMethodName());
    methodParamList = new ArrayList<PropertyInfo>();
}
protected String getUrl()
{
    return URL;
}
protected void setUrl(String url)
{
    URL = url;
}
protected String getMethodName()
{
    return MethodName;
}
protected void setMethodName(String methodName)
{
    MethodName = methodName;
}
protected String getNamespace()
{
    return Namespace;
}
protected void setNamespace(String namespace)
{
    Namespace = namespace;
}
protected String SoapAction()
{
    String SOAP_ACTION = this.getNamespace() + this.getMethodName();
    return SOAP_ACTION;
}
protected void CreateSoapRequest() throws Exception
{
    try
    {
        if(methodParamList.size()>0){
            for(PropertyInfo propInfo : methodParamList)
            {
        SoapRequest.addProperty(propInfo.getName(), propInfo.getValue());
            }
        }
    }catch(Exception ex){
        throw ex;
    }

}
public <T> void addMethodParameters(String paramName, T val)
{
    PropertyInfo prop = new PropertyInfo();
    prop.setName(paramName);
    prop.setValue(val);
    prop.setType(val.getClass());
    methodParamList.add(prop);
}
protected SoapSerializationEnvelope createEnvelope() throws Exception
{
    this.CreateSoapRequest();
    try{

        Envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        Envelope.dotNet = true;
        Envelope.setOutputSoapObject(SoapRequest);

    }catch(Exception ex){
        throw ex;
    }
    return Envelope;
}
public String getResponse() throws Exception
{
    try{

        this.createEnvelope();

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

           androidHttpTransport.call(this.SoapAction(), Envelope);

           Response = (SoapPrimitive) Envelope.getResponse();

    }catch(Exception ex){
        throw ex;
    }
    return Response.toString();
}

}

您可以调整它以使用各种网页 url 而不是 web 服务 url。

于 2012-06-06T01:08:41.517 回答