亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? dec01_ericg.txt

?? TechTips j2me的常用技巧. 網絡功能
?? TXT
?? 第 1 頁 / 共 2 頁
字號:

 J 2 M E    T  E  C  H    T  I  P  S

                      TIPS, TECHNIQUES, AND SAMPLE CODE


WELCOME to the Java Developer Connection(sm) (JDC)
Java(tm) 2 Platform, Micro Edition (J2ME(tm)) 
Tech Tips, for December 17, 2001. This issue covers:

     * Data Encryption for J2ME Profiles
     * Validating Input Using the ItemStateListener Interface
         
The J2ME Tech Tips are written by Eric Giguere
(http://www.ericgiguere.com), an engineer at iAnywhere 
Solutions, inc. Eric is the author of the book "Java 2 Micro
Edition: Professional Developer's Guide" and co-author of the 
book "Mobile Information Device Profile for Java 2 Micro 
Edition," both books in John Wiley & Sons' Professional 
Developer's Guide series.

You can view this issue of the J2ME Tech Tips on the Web at
http://java.sun.com/jdc/J2METechTips/2001/tt1217.html

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
DATA ENCRYPTION FOR J2ME PROFILES

If your J2ME applications store or transmit sensitive or 
confidential data, you can make them more secure using data 
encryption. Devices that support the Mobile Information Device 
Profile (MIDP), for example, are only required (in version 1.0) 
to support HTTP, not the secure HTTP protocol, HTTPS. The 
security of your data therefore depends on the security of the 
network. Even applications that don't transmit confidential
data can benefit from data encryption. When run on a Palm 
OS-based device, for example, the record stores used by a MIDP 
application are actually Palm OS record databases. The MIDP 
runtime system controls access to the underlying record 
databases so that only applications running the same MIDlet 
suite can see each other's data. However, it's a trivial matter
for an experienced Palm OS user to view and copy the contents of 
those databases independently from the MIDP runtime system.  
Encrypting the contents of a record store can defeat all but
the most determined attackers.

Unfortunately, encryption is not a standard part of either the 
Connected Device Configuration (CDC) or the Connected Limited 
Device Configuration (CLDC). You must either write your own 
encryption/decryption code or else use a class library. Writing 
your own code is not a recommended approach because of the 
complexity involved in selecting and implementing the appropriate
algorithms. Instead, it's better to take advantage of existing
code. That's where the Legion of the Bouncy Castle comes in.

The Legion of the Bouncy Castle is an open source Java encryption 
project hosted at http://www.bouncycastle.org. Although primarily 
geared towards providing alternative encryption algorithms for 
J2SE(tm), the Legion has adapted some of its code to work with 
J2ME. Specifically, parts of the Bouncy Castle lightweight 
cryptography API work with both the CLDC and the CDC. The 
lightweight API supports all the common block and stream 
encryptions, such as DES, Blowfish, IDEA, Rijndael, and RC4, as 
well as digest generation and key exchange, although not
all these features are available for all J2ME platforms.

To use the cryptography API, go to the Bouncy Castle web site and 
download the latest release of the lightweight API for J2ME. 
Extract the archive into a suitable directory. Although a 
midp_classes.zip file is provided with classes compiled and 
preverified, you're better off copying the source files you need 
directly into your project. That's because some of the Bouncy 
Castle classes refer to classes that are not found in the CLDC or
the MIDP. Second, you get a better idea of how much of a space 
penalty you pay for adding encryption support to your application.

Here is an example of a simple encryption class built using the 
Bouncy Castle lightweight API:

import org.bouncycastle.crypto.*;
import org.bouncycastle.crypto.engines.*;
import org.bouncycastle.crypto.modes.*;
import org.bouncycastle.crypto.params.*;

// A simple example that uses the Bouncy Castle
// lightweight cryptography API to perform DES
// encryption of arbitrary data.

public class Encryptor {

    private BufferedBlockCipher cipher;
    private KeyParameter        key;

    // Initialize the cryptographic engine.
    // The key array should be at least 8 bytes long.

    public Encryptor( byte[] key ){
        cipher = new PaddedBlockCipher(
                    new CBCBlockCipher(
                       new DESEngine() ) );

        this.key = new KeyParameter( key );
    }

    // Initialize the cryptographic engine.
    // The string should be at least 8 chars long.

    public Encryptor( String key ){
        this( key.getBytes() );
    }

    // Private routine that does the gritty work.

    private byte[] callCipher( byte[] data )
                        throws CryptoException {
        int    size = 
                   cipher.getOutputSize( data.length );
        byte[] result = new byte[ size ];
        int    olen = cipher.processBytes( data, 0,
                              data.length, result, 0 );
        olen += cipher.doFinal( result, olen );

        if( olen < size ){
            byte[] tmp = new byte[ olen ];
            System.arraycopy( 
                             result, 0, tmp, 0, olen );
            result = tmp;
        }

        return result;
    }

    // Encrypt arbitrary byte array, returning the
    // encrypted data in a different byte array.

    public synchronized byte[] encrypt( byte[] data )
                  throws CryptoException {
        if( data == null || data.length == 0 ){
            return new byte[0];
        }

        cipher.init( true, key );
        return callCipher( data );
    }

    // Encrypts a string.

    public byte[] encryptString( String data )
                  throws CryptoException {
        if( data == null || data.length() == 0 ){
            return new byte[0];
        }

        return encrypt( data.getBytes() );
    }

    // Decrypts arbitrary data.

    public synchronized byte[] decrypt( byte[] data )
                  throws CryptoException {
        if( data == null || data.length == 0 ){
            return new byte[0];
        }

        cipher.init( false, key );
        return callCipher( data );
    }

    // Decrypts a string that was previously encoded
    // using encryptString.

    public String decryptString( byte[] data )
                    throws CryptoException {
        if( data == null || data.length == 0 ){
            return "";
        }

        return new String( decrypt( data ) );
    }
}

The constructor defines the encryption algorithm to use by 
instantiating the appropriate encryption engine, in this case 
DESEngine, which represents the 56-bit DES algorithm:  

    public Encryptor( byte[] key ){
            cipher = new PaddedBlockCipher(
                        new CBCBlockCipher(
                           new DESEngine() ) );

DES works with 8-byte blocks. In order to be able to encrypt or 
decrypt data of arbitrary length, the constructor wraps the 
engine using PaddedBlockCipher and CDCBlockCipher. This produces 
a "cipher" object that does the encryption or decryption. The
cipher object must be initialized before it is used so that it 
knows whether it should encrypt or decrypt, and what key to use.  

The callCipher routine is where the encryption or decryption
actually occurs.

    private byte[] callCipher( byte[] data )
                        throws CryptoException {
            int    size = 
                   cipher.getOutputSize( data.length ); ...
  
To encrypt or decrypt data in your application, create an 
instance of this class, passing in the secret key. The secret key
must be at least eight bytes or characters long:

    Encryptor encryptor = 
                new Encryptor( "ghk23rTX" );
   
Note that because the encryption algorithm used in the example 
Encryptor class is the DES 56-bit algorithm, only the first eight 
characters or bytes of the key are used. If you change the class
to use one of the other engines, different limits apply.

Call the encrypt and decrypt methods to encrypt or decrypt 
arbitrary binary data. The convenience methods encryptString and 
decryptString make it easy to encrypt or decrypt strings by 
automatically converting them to and from byte arrays.

Here is a simple MIDP application that uses the Encryptor class 
to encrypt and decrypt a string stored in a record store. The
application prompts the user for an eight-character key. It then 
encrypts a user-defined message. The user can then enter 
different keys and see the result: either gibberish or an 
exception. Only the correct key will decrypt and display the 
message.

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.rms.*;

import org.bouncycastle.crypto.*;

// Simple test of encryption/decryption routines.

public class CryptoTest extends MIDlet {

    private Display display;
    private Command exitCommand =
                         new Command( "Exit",
                                     Command.EXIT, 1 ); 
    private Command okCommand =
                         new Command( "OK",
                                      Command.OK, 1 );

    private Encryptor   encryptor;
    private RecordStore rs;

    public CryptoTest(){
    }

    protected void destroyApp( boolean unconditional )
                    throws MIDletStateChangeException {
        exitMIDlet();
    }

    protected void pauseApp(){
    }

    protected void startApp()
                    throws MIDletStateChangeException {
        if( display == null ){ // first time called...
            initMIDlet();
        }
    }

    private void initMIDlet(){
        display = Display.getDisplay( this );

        // Open a record store here

        try {
            rs = RecordStore.openRecordStore( "test",
                                    true );
        }
        catch( RecordStoreException e ){
            // put in error handling here
        }

        display.setCurrent( new AskForKey() );
    }

    public void exitMIDlet(){
        try {
            if( rs != null ){
                rs.closeRecordStore();
            }
        }
        catch( RecordStoreException e ){
        }

        notifyDestroyed();
    }

    private void displayException( Exception e ){
        Alert a = new Alert( "Exception" );
        a.setString( e.toString() );
        a.setTimeout( Alert.FOREVER );
        display.setCurrent( a, new AskForKey() );
    }

    class AskForKey extends TextBox
                    implements CommandListener {
        public AskForKey(){
            super( "Enter a secret key:", "", 8, 0 );
            setCommandListener( this );
            addCommand( okCommand );
            addCommand( exitCommand );
        }

        public void commandAction( Command c,
                                   Displayable d ){
            if( c == exitCommand ){
                exitMIDlet();
            } 

            String key = getString();
            if( key.length() < 8 ){
                Alert a = new Alert( "Key too short" );
                a.setString( "The key must be " +
                             "8 characters long" );
                setString( "" );
                display.setCurrent( a, this );
                return;
            }

            encryptor = new Encryptor( key );

            try {
                if( rs.getNextRecordID() == 1 ){
                    display.setCurrent(
                                  new EnterMessage() );
                } else {
                    byte[] data = rs.getRecord( 1 );
                    String str = 
                       encryptor.decryptString( data );

                    Alert a = 
                             new Alert( "Decryption" );
                    a.setTimeout( Alert.FOREVER );
                    a.setString( 
                          "The decrypted string is '" +
                                 str + "'" );
                    display.setCurrent( a, this );
                }
            }
            catch( RecordStoreException e ){
                displayException( e );
            }
            catch( CryptoException e ){
                displayException( e );
            }
        }
    }

    class EnterMessage extends TextBox
                       implements CommandListener {
        public EnterMessage(){
            super( "Enter a message to encrypt:", "",
                   100, 0 );
            setCommandListener( this );
            addCommand( okCommand );
        }

        public void commandAction( Command c,
                                   Displayable d ){
            String msg = getString();

            try {
                byte[] data =
                      encryptor.encryptString( msg );
                rs.addRecord( data, 0, data.length );
            }
            catch( RecordStoreException e ){
                displayException( e );
            }
            catch( CryptoException e ){
                displayException( e );
            }

            display.setCurrent( new AskForKey() );
        }
    }
}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VALIDATING INPUT USING THE ITEMSTATELISTENER INTERFACE

The Mobile Information Device Profile's high-level user interface 
API defines several components for placement on Form objects.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久这里只有精品视频网| 91久久精品日日躁夜夜躁欧美| 一区二区三区精品在线观看| 国产人成一区二区三区影院| 欧美精品第一页| 欧美日本视频在线| 欧美美女视频在线观看| 欧美三级三级三级| 欧美精品v国产精品v日韩精品| 欧美撒尿777hd撒尿| 欧美日韩专区在线| 欧美一区二区三区人| 日韩女优制服丝袜电影| 精品久久久久久久久久久久久久久久久 | bt欧美亚洲午夜电影天堂| 国产东北露脸精品视频| 成人精品免费看| 99精品在线观看视频| 一本到不卡免费一区二区| 欧美熟乱第一页| 日韩一区二区电影在线| 精品粉嫩超白一线天av| 久久久不卡网国产精品一区| 国产女主播一区| 亚洲资源中文字幕| 精品一区二区成人精品| 成人一区二区视频| 欧美私模裸体表演在线观看| 7777精品伊人久久久大香线蕉| 精品免费视频.| 国产精品色一区二区三区| 亚洲欧美日韩中文播放| 日韩国产精品久久| 成人晚上爱看视频| 欧美系列日韩一区| 久久久久久久免费视频了| 国产精品久久久久影视| 日日欢夜夜爽一区| 国产成人亚洲综合a∨猫咪| 欧美在线免费观看亚洲| 精品黑人一区二区三区久久| 亚洲欧洲韩国日本视频| 免费高清成人在线| 91理论电影在线观看| 制服.丝袜.亚洲.另类.中文 | 成人丝袜18视频在线观看| 色94色欧美sute亚洲13| 日韩你懂的电影在线观看| 18成人在线观看| 国产综合色产在线精品| 欧美亚洲国产一卡| 欧美国产乱子伦| 欧美日精品一区视频| 蜜桃av一区二区在线观看| fc2成人免费人成在线观看播放| 7777精品伊人久久久大香线蕉超级流畅 | 欧美一区二区三区爱爱| 亚洲少妇30p| 国产福利一区二区三区视频在线 | 国产精品羞羞答答xxdd| 日韩一卡二卡三卡四卡| 亚洲一区在线播放| 99精品视频在线观看| 精品人在线二区三区| 亚洲成a人片在线不卡一二三区 | 欧美午夜在线观看| 亚洲免费观看高清| 成人免费av网站| 久久蜜桃一区二区| 精品午夜一区二区三区在线观看| 欧亚洲嫩模精品一区三区| 国产精品乱人伦| 国产a久久麻豆| 国产日韩欧美精品电影三级在线| 麻豆免费看一区二区三区| 欧美日韩综合一区| 五月天中文字幕一区二区| 色婷婷av一区二区三区gif | 欧美日韩成人高清| 亚洲已满18点击进入久久| 91麻豆免费视频| 亚洲黄网站在线观看| 在线观看日韩av先锋影音电影院| 日韩理论片中文av| 91黄视频在线| 亚洲第一搞黄网站| 日韩免费电影网站| 国产精一区二区三区| 国产精品免费视频观看| 99久久国产免费看| 亚洲一区免费在线观看| 欧美疯狂性受xxxxx喷水图片| 亚洲成人动漫av| 日韩视频一区二区| 国产精品一级片| 亚洲欧洲av另类| 色美美综合视频| 日韩国产欧美在线观看| 久久影院午夜论| aaa欧美色吧激情视频| 亚洲一二三四区不卡| 日韩美女一区二区三区四区| 国产精品影视网| 亚洲欧美日韩在线| 欧美日韩国产另类一区| 国内精品在线播放| 亚洲欧美激情视频在线观看一区二区三区 | 欧美一级黄色大片| 国产成人在线视频网址| 亚洲一卡二卡三卡四卡五卡| 欧美精品一区视频| 色噜噜狠狠色综合中国| 久久狠狠亚洲综合| 中文字幕一区二区三区视频| 69成人精品免费视频| 丁香激情综合五月| 青娱乐精品在线视频| 亚洲丝袜制服诱惑| 日韩欧美国产一区二区三区| aaa亚洲精品一二三区| 麻豆精品新av中文字幕| 中文字幕乱码亚洲精品一区| 国产成人在线免费观看| 精品视频全国免费看| 激情国产一区二区| 亚洲欧美日韩在线| 久久精品人人做人人爽人人| 91偷拍与自偷拍精品| 国产综合久久久久久鬼色| 亚洲精品视频在线观看网站| 欧美一区二区三区在线电影| 99国产精品国产精品毛片| 日韩在线卡一卡二| 一区二区免费在线播放| 欧美不卡视频一区| 欧美日韩成人高清| 成人免费看片app下载| 老司机精品视频线观看86| 亚洲国产高清aⅴ视频| 日韩亚洲欧美一区| 91小视频在线| 成人高清视频免费观看| 日韩国产高清在线| 日韩福利视频网| 色一情一乱一乱一91av| 国产69精品一区二区亚洲孕妇| 国产精品久久久久三级| 2021久久国产精品不只是精品| 欧美日韩成人一区二区| 色琪琪一区二区三区亚洲区| 色悠悠久久综合| 成人免费福利片| voyeur盗摄精品| 国产一区二区网址| 豆国产96在线|亚洲| 亚洲自拍与偷拍| 亚洲区小说区图片区qvod| 国产欧美精品区一区二区三区| 欧美美女喷水视频| 精品视频在线免费| 欧美一区二区免费观在线| 色国产精品一区在线观看| 91国偷自产一区二区使用方法| 国产精品一区二区男女羞羞无遮挡| 国产伦精品一区二区三区免费迷| 中文字幕在线不卡| 国产精品高清亚洲| 亚洲影院理伦片| 亚洲影院久久精品| 久久aⅴ国产欧美74aaa| 午夜成人免费视频| 久久66热re国产| 亚洲国产精品久久不卡毛片| 亚洲国产一区二区在线播放| 视频一区视频二区中文| 日本中文字幕一区二区视频 | 亚洲天堂精品视频| 亚洲最色的网站| 午夜精品福利在线| 精品影视av免费| 国产中文字幕精品| 91一区二区在线| 3751色影院一区二区三区| 日韩欧美精品在线| 国产精品成人免费在线| 精品国产污污免费网站入口| 国产精品拍天天在线| 亚洲一区二区三区美女| 青草国产精品久久久久久| 99久免费精品视频在线观看| 色综合天天综合在线视频| 日韩视频在线观看一区二区| 日韩三区在线观看| 中文字幕第一区综合| 国产午夜精品美女毛片视频| 中文子幕无线码一区tr| 午夜精品免费在线| 日韩精品福利网| 91麻豆文化传媒在线观看| 精品剧情在线观看|