我正在Android中实现RSA加密和解密的演示.我可以很好地执行加密,但在解密中我得到一个例外:>>java.security.InvalidKeyException: unknown key type passed to RSA.
KeyPairGenerator kpg;
KeyPair kp;
PublicKey publicKey;
PrivateKey privateKey;
byte [] encryptedBytes,decryptedBytes;
Cipher cipher,cipher1;
String encrypted,decrypted;
public String RSAEncrypt (final String plain) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException
{
kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(1024);
kp = kpg.genKeyPair();
publicKey = kp.getPublic();
privateKey = kp.getPrivate();
cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
encryptedBytes = cipher.doFinal(plain.getBytes());
encrypted = new String(encryptedBytes);
System.out.println("EEncrypted?????"+encrypted);
return encrypted;
}
public String RSADecrypt (final String result) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException
{
cipher1=Cipher.getInstance("RSA"); …Run Code Online (Sandbox Code Playgroud) 我有1个.bar文件,它是从eclipse插件生成的.
现在我想在Blackberry 10模拟器中测试那个.bar文件.
我该如何测试该应用程序?
我已经成功安装了黑莓模拟器10 Dev Alpha并配置了IP地址.
请帮我.提前致谢.
eclipse eclipse-plugin blackberry-simulator blackberry-eclipse-plugin blackberry-10
我想在Device上逐步调试我的应用程序.我的应用程序包含蓝牙和打印机代码,因此我只需要在设备上测试我的应用程序.如何在设备上调试我的应用程序,我的日志可以在Netbeans中看到.那有什么解决方案吗?我在某个地方得到了Exception,但我没有得到问题所在.如果您有任何想法,请帮助我.谢谢..
我想在J2ME应用程序中使用蓝牙打印一些打印机数据.我可以完美地打印数据但在完成打印功能后,打印机会自动关闭.我的意思是设备连接丢失,当我关闭应用程序时,它会自动打开.打印一次后,我不明白为什么连接会丢失.如果有人有任何想法,请帮助我.谢谢.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.mobifin;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import com.sun.lwuit.Command;
import com.sun.lwuit.Component;
import com.sun.lwuit.Dialog;
import com.sun.lwuit.Display;
import com.sun.lwuit.Font;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.List;
import com.sun.lwuit.TextArea;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.list.ListCellRenderer;
import com.sun.lwuit.plaf.Border;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import …Run Code Online (Sandbox Code Playgroud) 我想在标签字段中水平滚动。

我正在自定义 GridField Manager 中添加此 LabelField。这是自定义 GridField 管理器的代码。
public class CustomGridFieldManager extends Manager {
private int[] columnWidths;
private int columns;
private int allRowHeight = -1;
public CustomGridFieldManager(int columns, long style) {
super(style);
this.columns = columns;
}
public CustomGridFieldManager(int[] columnWidths, long style) {
super(style);
this.columnWidths = columnWidths;
this.columns = columnWidths.length;
}
public CustomGridFieldManager(int[] columnWidths, int rowHeight, long style) {
this(columnWidths, style);
this.allRowHeight = rowHeight;
}
protected boolean navigationMovement(int dx, int dy, int status, int time) {
int focusIndex = getFieldWithFocusIndex();
while(dy …Run Code Online (Sandbox Code Playgroud) 如何在BlackBerry中以编程方式发送短信?
我在某处读到,我需要服务器端以及客户端代码来发送短信.这是真的吗?要将消息从1个设备发送到另一个设备或从仿真器发送到设备,我真的需要服务器端和客户端代码吗?
我在客户端找到了这个代码,但我没有得到输出.
private void sendSMS(String phone, String message) throws RuntimeException, ServicesManagerException, IOException
{
// TODO Auto-generated method stub
System.out.println("in send sms function");
MessageConnection conn =
(MessageConnection)Connector.open("sms://+919099087960");
BinaryMessage msgOut = (BinaryMessage) conn.newMessage(MessageConnection.BINARY_MESSAGE);
msgOut.setPayloadData("my binary payload".getBytes("UTF-8"));
conn.send(msgOut);
}
Run Code Online (Sandbox Code Playgroud) sms blackberry blackberry-jde blackberry-simulator sms-gateway
我试图从J2ME应用程序发送短信,但我得到NullPointer异常.这是我的整个代码.如果您有任何想法,请帮助我.非常感谢...我正在使用MessageConnection在J2ME中发送短信.请纠正我错在哪里.
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.wireless.messaging.*;
public class SendSms extends MIDlet implements CommandListener {
Display display;
private TextField toWhom;
private TextField message;
private Alert alert;
private Command send, exit;
MessageConnection clientConn;
private Form compose;
public SendSms() {
display = Display.getDisplay(this);
compose = new Form("Compose Message");
toWhom = new TextField("To", "", 10, TextField.PHONENUMBER);
message = new TextField("Message", "", 600, TextField.ANY);
send = new Command("Send", Command.BACK, 0);
exit = new Command("Exit", Command.SCREEN, 5);
compose.append(toWhom);
compose.append(message);
compose.addCommand(send);
compose.addCommand(exit);
compose.setCommandListener(this);
} …Run Code Online (Sandbox Code Playgroud) 我在Box Layout中显示主窗体.在该框布局中,将Label放在另一个已设置为边框布局的容器中.现在这个容器被添加到主窗体中.
以下是我的代码: -
lblversion=new Label((String)keyvalues.get("lbl_versionnumber"));
lblversion.setAlignment(lblversion.RIGHT);
lblversion.setVerticalAlignment(lblversion.BOTTOM);
Container row0= new Container(new BorderLayout());
row0.addComponent(BorderLayout.SOUTH,lblversion);
this.addComponent(row0);
Run Code Online (Sandbox Code Playgroud)
现在我的问题是我想在屏幕底部显示标签,但它显示所有组件已添加到窗体中(而不是在底部).
我还附上了图片......你可以看到并了解它.
那么有没有选择在J2ME中使用LWUIT在屏幕底部设置标签?
如果有人有想法,请帮助我.
java-me ×4
blackberry ×2
bluetooth ×2
lwuit ×2
printing ×2
sms ×2
sms-gateway ×2
android ×1
debugging ×1
eclipse ×1
encryption ×1
java ×1
labelfield ×1
lwuit-form ×1
lwuit-label ×1
netbeans ×1
rsa ×1
send ×1