日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

J2ME手机文件加密

發(fā)布時(shí)間:2025/3/20 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 J2ME手机文件加密 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

最近剛剛學(xué)習(xí)J2ME??真可惜 J2ME的類太少 功能太弱了!哎~..... 而且什么東西都受安全限制,不過(guò)也有很多因素是硬件方面的!而且當(dāng) CLASS訪問(wèn)本地文件的時(shí)候,需要在文件訪問(wèn)權(quán)限那里開啟

package cn.isto;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;
/**
?*
?* @author Administrator
?*/
public class EncryptTool extends MIDlet implements CommandListener {
???
??? /** Creates a new instance of HelloMidlet */
??? public EncryptTool() {
??? }
???
??? private Form Encrypt;????????????????????
??? private Command exitCommand;
??? private TextField filepath;
??? private TextField enterpass;
??? private TextField againpass;
??? private ChoiceGroup choiceTypeGroup;
??? private Command okCommand;
??? private TextField outputPath;
??? private Spacer spacer1;
??? private Gauge gauge1;
??? private Ticker tickerMsg;??????????????????

????????????????????

??? /** This method initializes UI of the application.???????????????????????
???? */
??? private void initialize() {?????????????????????
?// Insert pre-init code here
??????? getDisplay().setCurrent(get_Encrypt());?????????????????????
?// Insert post-init code here
??? }????????????????????
???
??? /** Called by the system to indicate that a command has been invoked on a particular displayable.?????????????????????
???? * @param command the Command that ws invoked
???? * @param displayable the Displayable on which the command was invoked
???? */
??? public void commandAction(Command command, Displayable displayable) {???????????????????
??????? // Insert global pre-action code here
??????? if (displayable == Encrypt) {????????????????????
??????????? if (command == exitCommand) {??????????????????
??????????????? // Insert pre-action code here
??????????????? exitMIDlet();??????????????????????
??????????????? // Insert post-action code here
??????????? } else if (command == okCommand) {????????????????????
??????????????? tickerMsg.setString("kj021320簡(jiǎn)單加密程序");
??????????????? String operateFile=filepath.getString();
??????????????? String outputFile=outputPath.getString();
??????????????? InputStream fileR=null;
??????????????? OutputStream fileW=null;
??????????????? if((operateFile!=null&&!"".equals(operateFile))&&(outputPath!=null&&!"".equals(outputPath))){
??????????????????? if(enterpass.getString().equals(againpass.getString())){
??????????????????????? int pas=getPass(enterpass.getString());
??????????????????????? try {
??????????????????????????? fileR=Connector.openInputStream(operateFile);
??????????????????????????? fileW=Connector.openOutputStream(outputFile);
??????????????????????????? int b=fileR.read();
??????????????????????????? int xorB=0;
??????????????????????????? while(b!=-1){
??????????????????????????????? xorB= b ^ pas;
??????????????????????????????? fileW.write(xorB);
??????????????????????????????? b=fileR.read();
??????????????????????????? }
??????????????????????????? tickerMsg.setString("加密成功 你的密碼為 "+enterpass.getString()+" 請(qǐng)記住");
??????????????????????? } catch (Exception ex) {
??????????????????????????? tickerMsg.setString("加密失敗~ 有錯(cuò)誤"+ex.toString());
??????????????????????????? ex.printStackTrace();
??????????????????????? } finally{
??????????????????????????? try{fileR.close();}catch(Exception e){}
??????????????????????????? try{fileW.close();}catch(Exception e){}
??????????????????????? }
??????????????????? }else{
??????????????????????? tickerMsg.setString("兩次輸入的密碼不一樣");
??????????????????? }
??????????????? }else{
??????????????????? tickerMsg.setString("文件路徑不能為空");
??????????????? }
???????????????
??????????????? // Do nothing???????????????????????
??????????????? // Insert post-action code here
??????????? }??????????????????????
??????? }????????????????????
??????? // Insert global post-action code here
}??????????????????
??? public int getPass(String pass){
??????? byte[] passes=pass.getBytes();
??????? int result=0;
??????? for(int len=0;len<passes.length;len++){
??????????? result+=passes[len];
??????? }
??????? return result;
??? }
??? /**
???? * This method should return an instance of the display.
???? */
??? public Display getDisplay () {????????????????????????
??????? return Display.getDisplay(this);
??? }???????????????????????
???
??? /**
???? * This method should exit the midlet.
???? */
??? public void exitMIDlet () {????????????????????????
??????? getDisplay().setCurrent(null);
??????? destroyApp(true);
??????? notifyDestroyed();
??? }???????????????????????
???
??? /** This method returns instance for Encrypt component and should be called instead of accessing Encrypt field directly.???????????????????????
???? * @return Instance for Encrypt component
???? */
??? public Form get_Encrypt() {
??????? if (Encrypt == null) {?????????????????????
??????????? // Insert pre-init code here
??????????? Encrypt = new Form(null, new Item[] {??????????????????????
??????????????? get_filepath(),
??????????????? get_outputPath(),
??????????????? get_enterpass(),
??????????????? get_againpass(),
??????????????? get_choiceTypeGroup()
??????????? });
??????????? Encrypt.addCommand(get_exitCommand());
??????????? Encrypt.addCommand(get_okCommand());
??????????? Encrypt.setCommandListener(this);
??????????? Encrypt.setTicker(get_tickerMsg());????????????????????
??????????? // Insert post-init code here
??????? }?????????????????????
??????? return Encrypt;
??? }???????????????????
???
???
??? /** This method returns instance for exitCommand component and should be called instead of accessing exitCommand field directly.???????????????????????
???? * @return Instance for exitCommand component
???? */
??? public Command get_exitCommand() {
??????? if (exitCommand == null) {?????????????????????
??????????? // Insert pre-init code here
??????????? exitCommand = new Command("Exit", Command.EXIT, 1);?????????????????????
??????????? // Insert post-init code here
??????? }?????????????????????
??????? return exitCommand;
??? }???????????????????
?
??? /** This method returns instance for filepath component and should be called instead of accessing filepath field directly.????????????????????????
???? * @return Instance for filepath component
???? */
??? public TextField get_filepath() {
??????? if (filepath == null) {??????????????????????
??????????? // Insert pre-init code here
??????????? filepath = new TextField("filePath:", null, 120, TextField.ANY);??????????????????????
??????????? // Insert post-init code here
??????? }??????????????????????
??????? return filepath;
??? }????????????????????

??? /** This method returns instance for enterpass component and should be called instead of accessing enterpass field directly.????????????????????????
???? * @return Instance for enterpass component
???? */
??? public TextField get_enterpass() {
??????? if (enterpass == null) {??????????????????????
??????????? // Insert pre-init code here
??????????? enterpass = new TextField("enterpass", null, 120, TextField.ANY | TextField.PASSWORD);??????????????????????
??????????? // Insert post-init code here
??????? }??????????????????????
??????? return enterpass;
??? }????????????????????

??? /** This method returns instance for againpass component and should be called instead of accessing againpass field directly.????????????????????????
???? * @return Instance for againpass component
???? */
??? public TextField get_againpass() {
??????? if (againpass == null) {??????????????????????
??????????? // Insert pre-init code here
??????????? againpass = new TextField("againpass", null, 120, TextField.ANY | TextField.PASSWORD);??????????????????????
??????????? // Insert post-init code here
??????? }??????????????????????
??????? return againpass;
??? }????????????????????
?

??? /** This method returns instance for choiceTypeGroup component and should be called instead of accessing choiceTypeGroup field directly.????????????????????????
???? * @return Instance for choiceTypeGroup component
???? */
??? public ChoiceGroup get_choiceTypeGroup() {
??????? if (choiceTypeGroup == null) {??????????????????????
??????????? // Insert pre-init code here
??????????? choiceTypeGroup = new ChoiceGroup("chooseType", Choice.POPUP, new String[0], new Image[0]);???????????????????????
??????????? choiceTypeGroup.setSelectedFlags(new boolean[0]);?????????????????????
??????????? // Insert post-init code here
??????????? choiceTypeGroup.insert(0,"encrypt",null);
??????????? choiceTypeGroup.insert(0,"decrypt",null);
??????? }??????????????????????
??????? return choiceTypeGroup;
??? }????????????????????

??? /** This method returns instance for okCommand component and should be called instead of accessing okCommand field directly.????????????????????????
???? * @return Instance for okCommand component
???? */
??? public Command get_okCommand() {
??????? if (okCommand == null) {??????????????????????
??????????? // Insert pre-init code here
??????????? okCommand = new Command("OK", Command.OK, 1);??????????????????????
??????????? // Insert post-init code here
??????? }??????????????????????
??????? return okCommand;
??? }????????????????????

??? /** This method returns instance for outputPath component and should be called instead of accessing outputPath field directly.????????????????????????
???? * @return Instance for outputPath component
???? */
??? public TextField get_outputPath() {
??????? if (outputPath == null) {??????????????????????
??????????? // Insert pre-init code here
??????????? outputPath = new TextField("outputPath:", null, 120, TextField.ANY);??????????????????????
??????????? // Insert post-init code here
??????? }??????????????????????
??????? return outputPath;
??? }????????????????????

??? /** This method returns instance for spacer1 component and should be called instead of accessing spacer1 field directly.????????????????????????
???? * @return Instance for spacer1 component
???? */
??? public Spacer get_spacer1() {
??????? if (spacer1 == null) {??????????????????????
??????????? // Insert pre-init code here
??????????? spacer1 = new Spacer(1000, 1);??????????????????????
??????????? // Insert post-init code here
??????? }??????????????????????
??????? return spacer1;
??? }????????????????????

??? /** This method returns instance for gauge1 component and should be called instead of accessing gauge1 field directly.????????????????????????
???? * @return Instance for gauge1 component
???? */
??? public Gauge get_gauge1() {
??????? if (gauge1 == null) {??????????????????????
??????????? // Insert pre-init code here
??????????? gauge1 = new Gauge("gauge1", false, 100, 50);??????????????????????
??????????? // Insert post-init code here
??????? }??????????????????????
??????? return gauge1;
??? }????????????????????

??? /** This method returns instance for tickerMsg component and should be called instead of accessing tickerMsg field directly.????????????????????????
???? * @return Instance for tickerMsg component
???? */
??? public Ticker get_tickerMsg() {
??????? if (tickerMsg == null) {??????????????????????
??????????? // Insert pre-init code here
??????????? tickerMsg = new Ticker("kj021320/u7B80/u5355/u52A0/u5BC6/u7A0B/u5E8F");??????????????????????
??????????? // Insert post-init code here
??????? }??????????????????????
??????? return tickerMsg;
??? }????????????????????
????
??? public void startApp() {
??????? initialize();
??? }
???
??? public void pauseApp() {
??? }
???
??? public void destroyApp(boolean unconditional) {
??? }
}

程序采用 異或形式加密~ 所以加密就是解密...choosetype那個(gè)按扭是多余的!呵呵.忘記說(shuō)一點(diǎn)~ Connector不支持創(chuàng)建文件! 所以輸入和輸出文件必須要存在,-_-郁悶了吧! 本地文件協(xié)議如下例如

file:///c:/13.jpg?這樣才能訪問(wèn)本地文件

總結(jié)

以上是生活随笔為你收集整理的J2ME手机文件加密的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲欧美日韩中文字幕在线观看 | 狠狠狠狠狠狠狠 | 欧美成人黄色小视频 | 午夜精品福利在线观看 | 物业福利视频 | 久久精品国产亚洲av蜜臀色欲 | 插插射射 | 69视频国产 | a男人天堂 | 久久久久人妻精品色欧美 | 黄色永久视频 | 国产一级二级三级在线观看 | a在线播放| 国产无遮挡aaa片爽爽 | 中文字幕第12页 | 亚洲精品lv | 美女网站免费观看 | 奶水喷溅虐奶乳奴h文 | 日韩一区二区在线观看 | 亚洲不卡在线观看 | 四虎免费观看 | 精品少妇一二三区 | 中国黄色录像一级片 | 久人人 | 欧洲成人综合网 | 天天干夜夜操视频 | 黄视频网站在线观看 | 鬼灭之刃柱训练篇在线观看 | www色com| 中文字幕免费在线视频 | 国产人妖ts重口系列网站观看 | 亚洲一区二区三区日韩 | 五月天婷婷伊人 | 免费一级全黄少妇性色生活片 | 国产真实在线 | 免费国产区 | 久久发布国产伦子伦精品 | 久久精品一区二区三区四区 | 韩国伦理片在线看 | 国产男人的天堂 | 性欧美丰满熟妇xxxx性 | 亚洲av无码国产精品色午夜 | 精品久久久无码中文字幕边打电话 | 欧美日韩亚洲视频 | 国产女人高潮视频 | 插综合| 国产成人毛片 | 在线青草 | 久色资源 | 男女黄床上色视频免费的软件 | 人妻妺妺窝人体色www聚色窝 | 亚洲黄色三级视频 | 久久精品国产亚洲AV无码麻豆 | 日本xxxx免费 | 91美女在线| 国产白袜脚足j棉袜在线观看 | 天天亚洲 | av网站免费观看 | 天天视频黄色 | 在线国产播放 | 午夜激情一区二区 | 国产xxx | 久久涩涩| 日韩大片免费观看视频播放 | 久操视频在线免费观看 | av电影一区二区三区 | 亚洲精品影院在线 | 视频区图片区小说区 | 国产精品中文无码 | 精品91视频 | 日本三级中文字幕在线观看 | 国内自拍视频网站 | wwwxx日本 | 国模二区 | 51ⅴ精品国产91久久久久久 | 亚洲天堂一区二区三区 | 亚洲资源网站 | 91福利视频免费观看 | 加勒比av在线播放 | 国产成人精品亚洲男人的天堂 | 九九热视频精品在线观看 | 波多野结衣电影在线播放 | 黄色永久视频 | 国产精品精品久久久久久 | 日本69熟| 自拍偷拍亚洲天堂 | 一区二区有码 | 亚洲一区二区三区四 | 女人一级一片30分 | 天堂色网| 国产乱色精品成人免费视频 | 国产精选久久 | 欧美 日韩 国产 激情 | 欧洲一区二区在线观看 | 精品无码免费视频 | 国产l精品国产亚洲区久久 午夜青青草 | 奇米精品一区二区三区四区 | 国产日韩欧美高清 | 草草草在线视频 |