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

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

?? messagecodec.java

?? J2ME MIDP_Example_Applications
?? JAVA
字號:
// Copyright 2003 Nokia Corporation.
//
// THIS SOURCE CODE IS PROVIDED 'AS IS', WITH NO WARRANTIES WHATSOEVER,
// EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY, FITNESS
// FOR ANY PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE
// OR TRADE PRACTICE, RELATING TO THE SOURCE CODE OR ANY WARRANTY OTHERWISE
// ARISING OUT OF ANY PROPOSAL, SPECIFICATION, OR SAMPLE AND WITH NO
// OBLIGATION OF NOKIA TO PROVIDE THE LICENSEE WITH ANY MAINTENANCE OR
// SUPPORT. FURTHERMORE, NOKIA MAKES NO WARRANTY THAT EXERCISE OF THE
// RIGHTS GRANTED HEREUNDER DOES NOT INFRINGE OR MAY NOT CAUSE INFRINGEMENT
// OF ANY PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OWNED OR CONTROLLED
// BY THIRD PARTIES
//
// Furthermore, information provided in this source code is preliminary,
// and may be changed substantially prior to final release. Nokia Corporation
// retains the right to make changes to this source code at
// any time, without notice. This source code is provided for informational
// purposes only.
//
// Nokia and Nokia Connecting People are registered trademarks of Nokia
// Corporation.
// Java and all Java-based marks are trademarks or registered trademarks of
// Sun Microsystems, Inc.
// Other product and company names mentioned herein may be trademarks or
// trade names of their respective owners.
//
// A non-exclusive, non-transferable, worldwide, limited license is hereby
// granted to the Licensee to download, print, reproduce and modify the
// source code. The licensee has the right to market, sell, distribute and
// make available the source code in original or modified form only when
// incorporated into the programs developed by the Licensee. No other
// license, express or implied, by estoppel or otherwise, to any other
// intellectual property rights is granted herein.
import org.bouncycastle.crypto.*;
import org.bouncycastle.crypto.digests.*;
import org.bouncycastle.crypto.engines.*;
import org.bouncycastle.crypto.modes.*;
import org.bouncycastle.crypto.paddings.*;
import org.bouncycastle.crypto.params.*;
import java.io.*;

// The class MessageCodec encodes and decodes messages
class MessageCodec
{
  final static int OPTION_DIGEST = 0x1;


  // Creates a BlockCipher Engine, for example DES or AES
  static BlockCipher createEngine()
  {
    return new CBCBlockCipher(new DESEngine());
  }

  // Creates a Digest Engine, for example MD5 or SHA1
  static Digest createDigest()
  {
    return new MD5Digest();
  }


  // Do the encoding of the message including the headers,
  // encrypted content and digest
  static byte[] encodeMessage(String plainText,
                              String password,
                              boolean addDigest)
    throws Exception
  {
    byte content[] = plainText.getBytes();
    byte key[] = password.getBytes();

    // Create the cipher. Modify createEngine to use another Engine
    BufferedBlockCipher cipherEngine =
        new PaddedBufferedBlockCipher(createEngine());
    // Initialize the cipher for encryption
    cipherEngine.init(true, new KeyParameter(key));

    byte[] cipherText = new byte[cipherEngine.getOutputSize(content.length)];
    byte[] digest = null;

    // Do encryption
    int cipherTextLength = cipherEngine.processBytes(content,
                                                     0,
                                                     content.length,
                                                     cipherText,
                                                     0);
    cipherEngine.doFinal(cipherText, cipherTextLength);

    // add a digest if required
    if (addDigest)
    {
      Digest digestEngine = createDigest();
      int digestSize = digestEngine.getDigestSize();
      digest = new byte[digestSize];
      digestEngine.update(content, 0, content.length);
      digestEngine.doFinal(digest, 0);
    }

    // Create temporary streams
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    DataOutputStream dout = new DataOutputStream(out);

    // write length
    dout.writeShort(cipherText.length);
    // write options
    int options = (addDigest) ? OPTION_DIGEST : 0;

    dout.writeShort(options);
    // write cipher text
    out.write(cipherText);
    // write digest
    if (addDigest)
    {
      out.write(digest);
    }
    return out.toByteArray();
  }


  // Decodes a message reading the header,
  // decrypting the content and veryfing the password
  static String decodeMessage(byte[] messageContent, String password)
    throws Exception
  {
    byte key[] = password.getBytes();

    // create utility streams
    ByteArrayInputStream in = new ByteArrayInputStream(messageContent);
    DataInputStream din = new DataInputStream(in);

    // read the message content
    int cipherTextLength = din.readShort();
    int options = din.readShort();

    byte[] cipherText = new byte[cipherTextLength];
    in.read(cipherText, 0, cipherTextLength);

    byte[] digest = null;
    Digest digestEngine = createDigest();
    // If the message contains a digest read it
    if ((options & OPTION_DIGEST) == 1)
    {
      int digestSize = digestEngine.getDigestSize();
      digest = new byte[digestSize];
      in.read(digest, 0, digestSize);
    }

    // Create decryption engine
    BufferedBlockCipher cipherEngine =
        new PaddedBufferedBlockCipher(createEngine());
    // Initialize the cipher for decryption
    cipherEngine.init(false, new KeyParameter(password.getBytes()));

    byte[] plainText = new byte[cipherEngine.getOutputSize(cipherTextLength)];

    // do encryption
    int size = cipherEngine.processBytes(cipherText,
                                         0,
                                         cipherTextLength,
                                         plainText,
                                         0);
    cipherEngine.doFinal(plainText, size);

    // It is important to do trimming to remove possible padding
    String resultText = new String(plainText).trim();

    // verify the text digest
    if ((options & OPTION_DIGEST) == 1)
    {
      // calculate the digest of the resulting text
      plainText = resultText.getBytes();
      digestEngine.update(plainText, 0, plainText.length);
      byte[] calculatedDigest = new byte[digestEngine.getDigestSize()];

      digestEngine.doFinal(calculatedDigest, 0);
      // compare digests size
      if (calculatedDigest.length != digest.length)
      {
        throw new Exception("Digest size mismatch");
      }
      // compare byte per byte
      for (int i = 0; i < calculatedDigest.length; i++)
      {
        if (calculatedDigest[i] != digest[i])
        {
          throw new Exception("Digest misimatch. Integrity compromised");
        }
      }
    }
    return resultText;
  }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区中文字幕| 日韩午夜在线影院| 亚洲欧美日韩国产另类专区| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 丝袜诱惑制服诱惑色一区在线观看| 成人精品视频一区二区三区尤物| 国产精品婷婷午夜在线观看| 成人app在线| 午夜伦欧美伦电影理论片| 日韩三级免费观看| 精品一区二区综合| 欧美va亚洲va香蕉在线| www.欧美精品一二区| 亚洲福利一区二区三区| 久久久久久久久蜜桃| 欧美在线999| 国产一区二区三区黄视频 | 国产精品自拍在线| 一区二区三区电影在线播| 日韩欧美在线一区二区三区| 国产很黄免费观看久久| 亚洲午夜激情av| 久久久久久久久久久黄色| 欧美日韩精品一二三区| va亚洲va日韩不卡在线观看| 国产自产2019最新不卡| 国产欧美一区二区精品久导航| 亚洲欧洲av一区二区三区久久| 成人一二三区视频| 久久99久久精品| 首页国产丝袜综合| 亚洲色图清纯唯美| 国产精品国产三级国产aⅴ入口| 日韩天堂在线观看| 日韩欧美123| 91精品国产高清一区二区三区蜜臀| 99久久精品99国产精品| 成人小视频免费在线观看| 国产精品1024久久| 成人久久视频在线观看| 91网站在线播放| 在线免费视频一区二区| 欧美一卡二卡三卡| 久久蜜桃av一区二区天堂| 日韩欧美资源站| 91麻豆精品国产91久久久资源速度| 99re视频精品| 91精品国产综合久久久蜜臀粉嫩| 欧美一区二区播放| 国产精品人妖ts系列视频| 亚洲毛片av在线| 免费成人av资源网| av欧美精品.com| 在线观看日产精品| 日本一区二区三区四区在线视频| 亚洲欧美在线另类| 日本美女视频一区二区| 97超碰欧美中文字幕| 欧美精品少妇一区二区三区| 日本一区二区三区高清不卡| 亚洲国产另类av| 不卡欧美aaaaa| 欧美挠脚心视频网站| 国产日韩精品一区二区三区| 日韩精品免费专区| 99精品在线免费| 久久中文字幕电影| 美女爽到高潮91| 91高清在线观看| 亚洲天堂成人在线观看| 国内精品久久久久影院薰衣草| 欧美三片在线视频观看| 亚洲女子a中天字幕| 欧美在线高清视频| 亚洲精品国产品国语在线app| 国产成人综合在线观看| 久久青草欧美一区二区三区| 精品亚洲成a人在线观看| 91精品黄色片免费大全| 三级影片在线观看欧美日韩一区二区| 色又黄又爽网站www久久| 亚洲国产成人在线| 国模冰冰炮一区二区| 91精品国产色综合久久| 蜜臀a∨国产成人精品| 久久久久久一二三区| 99riav一区二区三区| 天天综合色天天| 久久午夜电影网| 97久久久精品综合88久久| 亚洲六月丁香色婷婷综合久久| 色综合久久88色综合天天| 日韩国产一区二| 国产精品视频免费| 欧美二区三区的天堂| 国产黄色成人av| 国产欧美日韩在线视频| 国产精品久久免费看| 成人涩涩免费视频| 午夜精品视频一区| 中文字幕一区av| 久久亚洲精华国产精华液 | 日本电影欧美片| 久久99久久99| 日韩激情在线观看| 亚洲日本在线a| 国产精品久久久久久久久久久免费看| 欧美视频第二页| 日本精品一区二区三区高清 | 国产suv一区二区三区88区| 亚洲一区二区三区中文字幕在线| 日韩精品资源二区在线| 欧美性淫爽ww久久久久无| 成人黄色在线看| 国产69精品久久久久毛片| 国产麻豆视频一区| 激情综合网av| 国产99精品在线观看| 国产精品一区三区| 成人黄色小视频| 91在线观看视频| 99国产欧美另类久久久精品| proumb性欧美在线观看| 成人在线综合网| 国产精品自拍三区| 99精品桃花视频在线观看| 北条麻妃国产九九精品视频| 91尤物视频在线观看| 91麻豆高清视频| 91精品国产色综合久久不卡电影 | 91精品国产欧美一区二区成人| 6080yy午夜一二三区久久| 精品日韩成人av| 亚洲精品少妇30p| 九色综合狠狠综合久久| 成人黄色国产精品网站大全在线免费观看 | 亚洲成a天堂v人片| 久久精品国产色蜜蜜麻豆| av在线播放不卡| 日韩一本二本av| 又紧又大又爽精品一区二区| 免费观看91视频大全| 色综合久久66| 久久精品日韩一区二区三区| 亚洲综合一区二区| 韩国理伦片一区二区三区在线播放| 成人精品视频.| 久久久久久电影| 久国产精品韩国三级视频| 在线免费观看日本欧美| 国产精品乱码一区二三区小蝌蚪| 色综合天天在线| 欧美午夜精品一区二区三区 | 日韩欧美久久久| 亚洲成人三级小说| 99久久免费精品| 亚洲国产精品ⅴa在线观看| 狠狠色伊人亚洲综合成人| 日韩一卡二卡三卡四卡| 亚洲一区二区免费视频| 91福利视频在线| 亚洲一区二区三区中文字幕| 欧美三级中文字幕| 日韩av一级片| 国产欧美一区二区精品仙草咪| 久久久久成人黄色影片| 亚洲一区二区在线播放相泽 | 天堂成人免费av电影一区| 91蜜桃免费观看视频| 亚洲综合一区二区精品导航| 色激情天天射综合网| 亚洲成av人片在线| 久久麻豆一区二区| 成人免费电影视频| 亚洲国产一区二区a毛片| 欧美久久久久中文字幕| 国内精品视频666| 中文字幕一区二区三区在线播放 | 麻豆传媒一区二区三区| 国产亚洲视频系列| 欧美日韩一区在线| 国内外成人在线| 亚洲午夜激情网页| 国产精品污www在线观看| 欧美一区二区免费视频| jlzzjlzz欧美大全| 麻豆成人免费电影| 婷婷久久综合九色国产成人| 中文字幕欧美三区| 精品精品国产高清一毛片一天堂| 波多野结衣在线一区| 青青草国产成人99久久| 亚洲欧美日韩人成在线播放| 国产亚洲1区2区3区| 日韩精品一区二区三区三区免费| 欧美日韩中文字幕一区| 91日韩在线专区| 91香蕉视频mp4| 国产乱理伦片在线观看夜一区| 午夜视黄欧洲亚洲|