a few business card




bloooog word clouds

KSoap in Blackberry

in blackberry, you can use ksoap api to connect .net web service. :)


public boolean LoginProcess(String userStr, String passStr) {
        boolean status = false;
        // new Thread(new Runnable() {
        // public void run() {
        String serviceUrl = getHTTPAdd();
        String serviceNamespace = "http://tempuri.org/";
        String soapAction = "http://tempuri.org/SecureLogin";
        SoapObject  rpc = new SoapObject(serviceNamespace, "SecureLogin");
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        envelope.bodyOut  = rpc;
        envelope.dotNet  = true;
        envelope.encodingStyle = SoapSerializationEnvelope.XSD;
        rpc.addProperty("customerid", userStr);
        rpc.addProperty("password", passStr);
        String payHelpString = ";interface=wifi";
        HttpTransport ht = new HttpTransport(serviceUrl + payHelpString);
        ht.debug = true;
        String result;
        try {
            ht.call(soapAction, envelope);
            result = (envelope.getResponse()).toString();
            resultOfWebCall = result;
            userParseData = toStringStr(parseSXml(result));
            checkVal = parseSXml(result)[1];
            userStrVal = parseSXml(result)[2]; // :)
            userStrAccVall = userStr;
            System.out.println("|||||||||||| |||||||||||| checkVal: " + checkVal);
            if (checkVal.compareTo("OK") == 0) {
                status = true;
            }
        } catch (Exception ex) {
            result = ex.toString();
            System.out.println(">>> inline error: "+result);
        }
        return status;
    }

Sms Encryption - Decryption

A few years ago, i tried to do a mobile sms cryption applicatio with bouncycastle.


public byte[] smsEncodedMessage ( byte[] smsEncContent , byte[] smsEncPKey ) throws Exception {
        try {
            cipherEngine = new PaddedBufferedBlockCipher ( createEngine () );
            cipherEngine.init ( true , new KeyParameter ( smsEncPKey ) );
            cipherText = new byte[ cipherEngine.getOutputSize ( smsEncContent.length ) ];
            cipherTextLength = cipherEngine.processBytes ( smsEncContent , 0 , smsEncContent.length , cipherText , 0 );
            cipherEngine.doFinal ( cipherText , cipherTextLength );
            out = new ByteArrayOutputStream ();
            dout = new DataOutputStream ( out );
            dout.writeShort ( cipherText.length );
            out.write ( cipherText );
        } catch ( Exception e ) {
            main.errorMessage ( "<ERROR BLOCK - inLine < 1 > >: " + e.getMessage () );
        }

        return out.toByteArray ();
    }

    public String smsDecodedMessage ( byte smsDecContent[] , byte[] smsDecPKey ) throws Exception {
        try {
            in = new ByteArrayInputStream ( smsDecContent );
            din = new DataInputStream ( in );
            cipherTextLength = din.readShort ();
            cipherText = new byte[ cipherTextLength ];
            in.read ( cipherText , 0 , cipherTextLength );
            cipherEngine = new PaddedBufferedBlockCipher ( createEngine () );
            cipherEngine.init ( false , new KeyParameter ( smsDecPKey ) );
            plainText = new byte[ cipherEngine.getOutputSize ( cipherTextLength ) ];
            size = cipherEngine.processBytes ( cipherText , 0 , cipherTextLength , plainText , 0 );
            cipherEngine.doFinal ( plainText , size );
            resultText = ( new String ( plainText ) ).trim ();
        } catch ( Exception e ) {
            main.errorMessage ( "<ERROR BLOCK - inLine < 2 > >: " + e.getMessage () );
        }
        return resultText;
    }