java - Error Input too large for RSA cipher on Android 5.0 -
i have problem "input large rsa cipher" adnroid 5.0 when use encrypt below:
public string rsaencryptstring(string strinputstring, int dwkeysize, publickey p) { stringbuilder stringbuilder = null; try { int keysize = dwkeysize / 8; byte[] bytes = strinputstring.getbytes("utf-32le"); int maxlength = keysize - 42; int datalength = bytes.length; int iterations = datalength / maxlength; stringbuilder = new stringbuilder(); cipher cipher = cipher.getinstance("rsa/ecb/oaepwithsha1andmgf1padding");//4.4 cipher.init(cipher.encrypt_mode, p); //cipher.init(cipher.decrypt_mode, p, new oaepparameterspec("sha-256", "mgf1", mgf1parameterspec.sha256, psource.pspecified.default)); (int = 0; <= iterations; i++) { int index = (datalength - maxlength * > maxlength) ? maxlength : datalength - maxlength * i; int offset = maxlength * i; byte[] tempbytes = new byte[index]; system.arraycopy(bytes, offset, tempbytes, 0, tempbytes.length); byte[] encryptedbytes = cipher.dofinal(tempbytes); byte[] encryptedbytes1 = onreverse(encryptedbytes); stringbuilder.append(base64.encodetostring(encryptedbytes1, base64.no_wrap)); } } catch (exception e) { e.printstacktrace(); } return stringbuilder.tostring(); }
but run @ android 4.4 below. should change algorithm correct version on android? thank answer.
Comments
Post a Comment