一、項(xiàng)目背景 隨著Internet技術(shù)和多媒體信息技術(shù)的飛速發(fā)展,多媒體、計(jì)算機(jī)網(wǎng)絡(luò)、個(gè)人移動(dòng)通信技術(shù)等進(jìn)入尋常百姓家,數(shù)字化已深入人心。數(shù)字多媒體信息在網(wǎng)上傳播與傳輸越來(lái)越方便,通過(guò)網(wǎng)絡(luò)傳遞各種信息越來(lái)越普遍。但與此同時(shí)也帶來(lái)了信息安全的隱患問(wèn)題。信息隱藏是近年來(lái)信息安全和多媒體信號(hào)處理領(lǐng)域中提出的一種解決媒體信息安全的新方法。它通過(guò)把秘密信息隱藏在可公開(kāi)的媒體信息里,達(dá)到證實(shí)該媒體信息的數(shù)據(jù)完整性或傳遞秘密信息的目的,從而為數(shù)字信息的安全問(wèn)題提供了一種新的解決方法。 二、軟件原理及內(nèi)容 1、原理 LSB(LeastSignificantBits)算法:將秘密信息嵌入到載體圖像像素值的最低有效位,也稱最不顯著位,改變這一位置對(duì)載體圖像的品質(zhì)影響最小。 LSB算法基本原理:對(duì)空域的LSB做替換,用來(lái)替換LSB的序列就是需要加入的水印信息、水印的數(shù)字摘要或者由水印生成的偽隨機(jī)序列。由于水印信息嵌入的位置是LSB,為了滿足水印的不可見(jiàn)性,允許嵌入的水印強(qiáng)度不可能太高。然而針對(duì)空域的各種處理,如游程編碼前的預(yù)處理,會(huì)對(duì)不顯著分量進(jìn)行一定的壓縮,所以LSB算法對(duì)這些操作很敏感。因此LSB算法最初是用于脆弱性水印的。 2、內(nèi)容 (1)編寫程序,能夠?qū)⒅辽?0個(gè)漢字隱藏到一幅24位的bmp格式的圖片中。 (2)用RSA算法將需要隱藏的信息進(jìn)行加密,然后再隱藏。 (3)能使用密鑰將隱藏信息解密提取出來(lái)。 三、實(shí)現(xiàn)步驟 1、找一幅bmp的24位圖片。 2、通過(guò)網(wǎng)絡(luò)學(xué)習(xí)RSA算法和LSB算法的相關(guān)原理和操作。 3、理清程序的運(yùn)行流程設(shè)計(jì)好頁(yè)面。 4、在NetBeansIDE編寫代碼實(shí)現(xiàn)相關(guān)功能。 5、調(diào)試程序并進(jìn)行優(yōu)化。 四、軟件功能及分析 1、工程結(jié)構(gòu)圖。
1.png (8.49 KB, 下載次數(shù): 58)
下載附件
2019-7-23 18:45 上傳
圖1 工程結(jié)構(gòu) 分析說(shuō)明: 圖1中PrivateKey為私鑰封裝類,Publickey為公鑰封裝類,RSAGeneratorKey為生成密鑰對(duì)的類,RSAUtil為含有加密和解密方法的封裝類,RsaKeyPair為密鑰對(duì)封裝類,_LSB_BMP為包含信息加密解密等方法的主類。 2、程序運(yùn)行初始界面。
2.png (12.32 KB, 下載次數(shù): 60)
下載附件
2019-7-23 18:47 上傳
圖2 初始界面 分析說(shuō)明: 圖2顯示的界面由標(biāo)題欄、菜單欄、圖片顯示區(qū)和文本輸入顯示區(qū)構(gòu)成。其中菜單欄中有文件、LSB和加密隱藏三個(gè)選項(xiàng),“文件”選項(xiàng)主要用于打開(kāi)已有的未加密圖片和加密圖片及保存隱藏信息后的圖片,打開(kāi)和保存的圖片均為bmp格式;“LSB”主要用于圖片的非加密隱藏和直接顯示隱藏信息;“加密隱藏”選項(xiàng)主要用于將所需的隱藏信息進(jìn)行RSA加密及將加密后的信息通過(guò)私鑰進(jìn)行解密。 3、點(diǎn)擊菜單欄中“文件”的“打開(kāi)”選項(xiàng),可選擇未加密信息的圖片或者含隱藏信息的圖片;若點(diǎn)擊“保存”選項(xiàng),則可以將含隱藏信息的圖片進(jìn)行保存。
3.png (22.67 KB, 下載次數(shù): 49)
下載附件
2019-7-23 18:47 上傳
圖3 選擇圖片路徑
4.png (262.63 KB, 下載次數(shù): 71)
下載附件
2019-7-23 18:47 上傳
圖4 打開(kāi)未隱藏信息的圖片
5.png (18.99 KB, 下載次數(shù): 50)
下載附件
2019-7-23 18:47 上傳
圖5 打開(kāi)隱藏信息的圖片
6.png (24.89 KB, 下載次數(shù): 54)
下載附件
2019-7-23 18:47 上傳
圖6 保存隱藏信息的圖片 分析說(shuō)明: 圖3中顯示的界面為選擇未隱藏信息的圖片或者隱藏了信息的圖片,圖4為打開(kāi)未隱藏信息的圖片后所出現(xiàn)的界面,且在文本輸入顯示區(qū)中顯示了可以嵌入多少字節(jié)的信息到圖片中;圖5為打開(kāi)含隱藏信息的圖片后的界面,可以看出含隱藏信息的圖片和原圖相比,憑肉眼是看不出區(qū)別的,但通過(guò)程序檢測(cè)卻能發(fā)現(xiàn)其中已經(jīng)隱藏了一定的信息;圖6為將含隱藏的圖片進(jìn)行保存,若保存成功會(huì)在文本輸入顯示區(qū)顯示“保存成功!”。 4、點(diǎn)擊菜單欄中的“加密隱藏”中的“隱藏”及“顯示”。
7.png (25.42 KB, 下載次數(shù): 60)
下載附件
2019-7-23 18:47 上傳
圖7 使用RSA對(duì)隱藏信息加密及保存私鑰
8.png (264.33 KB, 下載次數(shù): 50)
下載附件
2019-7-23 18:47 上傳
圖8 使用RSA私鑰對(duì)隱藏信息解密 分析說(shuō)明: 圖7中表示使用RSA算法將需隱藏的信息加密后,把RSA的私鑰通過(guò)文本保存的界面;圖8顯示的是通過(guò)選擇圖7保存的密鑰解密后,顯示的隱藏的信息。
源程序:
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package bmp;
- /**
- * @author 13673
- */
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.BufferedInputStream;
- import java.io.BufferedOutputStream;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.UnsupportedEncodingException;
- import java.math.BigInteger;
- import java.util.Enumeration;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.swing.JFileChooser;
- import javax.swing.JFrame;
- import javax.swing.JMenu;
- import javax.swing.JMenuBar;
- import javax.swing.JMenuItem;
- import javax.swing.JPanel;
- import javax.swing.JScrollPane;
- import javax.swing.JTextArea;
- import javax.swing.UIManager;
- import javax.swing.filechooser.FileNameExtensionFilter;
- import javax.swing.plaf.FontUIResource;
- /**
- *
- * @ClassName: 信息隱藏_LSB技術(shù)_于BMP位圖
- * @Description: 基于24位BMP圖片,運(yùn)用LSB技術(shù)對(duì)文本信息進(jìn)行隱藏
- * @author:
- * @date: 2019年5月3日
- */
- public class _LSB_BMP extends JFrame{
- private static final long serialVersionUID = 1L;
- RsaKeyPair keyPair=RSAGeneratorKey.generatorKey(1024);//產(chǎn)生Rsa密鑰對(duì)
- boolean open_flag=false; //是否打開(kāi)圖片
- int map[][];//保存像素顏色的數(shù)組 int 4個(gè)字節(jié)
- int length_byte_sum=0;
- MyPanel center;//繪圖面板
- File selectFile;//讀取的文件
- int width;//圖像寬度
- int height;//圖像高度
- byte temp1[];//圖像前18個(gè)字節(jié)的信息
- byte temp2[];//圖像的28個(gè)字節(jié)的信息
- JScrollPane scrollpane;//滑動(dòng)面板
- JTextArea infoJt;//文本信息區(qū)
- JMenuItem open; //打開(kāi)文件
- JMenuItem save;
- JMenuItem hide;
- JMenuItem show;
- JMenuItem hide_rsa;
- JMenuItem show_rsa;
- int disWidth=1000;
- int disHeight=800;
- public _LSB_BMP() {
- setUIFont(new FontUIResource("微軟雅黑", 0, 20)); //設(shè)置字體
- this.setLayout(new BorderLayout());//設(shè)置布局
- center=new MyPanel(); //初始化畫圖面板
- center.setBackground(Color.WHITE);
- center.setBackground(Color.GRAY);
- // center.setPreferredSize(new Dimension(200, 300));
- scrollpane=new JScrollPane(center);//用center初始化滾動(dòng)面板
- // scrollpane.setPreferredSize(new Dimension(200,100));
- infoJt=new JTextArea(); //隱藏信息輸入的控件
- infoJt.setLineWrap(true);
- infoJt.setWrapStyleWord(true);
- JScrollPane infoJs=new JScrollPane(infoJt);
- infoJs.setPreferredSize(new Dimension(disWidth, 300));
- MyListener lis=new MyListener(); //設(shè)置經(jīng)停事件
- JMenuBar menuBar=new JMenuBar();
- JMenu fileMenu=new JMenu("文件");
- open=new JMenuItem("打開(kāi)");
- save=new JMenuItem("保存");
- JMenu LSBMenu=new JMenu("LSB");
- hide=new JMenuItem("隱藏");
- show=new JMenuItem("顯示");
- JMenu RSAMenu=new JMenu("加密隱藏");
- hide_rsa=new JMenuItem("隱藏");
- show_rsa=new JMenuItem("顯示");
- open.addActionListener(lis);
- save.addActionListener(lis);
- hide.addActionListener(lis);
- show.addActionListener(lis);
- hide_rsa.addActionListener(lis);
- show_rsa.addActionListener(lis);
- fileMenu.add(open);
- fileMenu.add(save);
- menuBar.add(fileMenu);
- LSBMenu.add(hide);
- LSBMenu.add(show);
- menuBar.add(LSBMenu);
- RSAMenu.add(hide_rsa);
- RSAMenu.add(show_rsa);
- menuBar.add(RSAMenu);//添加到菜單欄
- this.setJMenuBar(menuBar);
- this.add(scrollpane,BorderLayout.CENTER);//加入滾動(dòng)面板
- this.add(infoJs,BorderLayout.SOUTH);
- this.setTitle("LSB隱藏器");
- this.setSize(disWidth, disHeight);
- this.setLocationRelativeTo(null);//設(shè)置窗體出現(xiàn)在屏幕中間
- this.setDefaultCloseOperation(3);
- this.setVisible(true);
- }
- /**
- * 讀取BMP文件
- */
- public void readBMP()
- {
- try {
- FileInputStream fis=new FileInputStream(selectFile); //選擇文件
- //讀取了一次就會(huì)依次往后移
- try (BufferedInputStream bis = new BufferedInputStream(fis) //輸入的緩沖區(qū)
- ) {
- //讀取了一次就會(huì)依次往后移
- byte[] wb=new byte[4];//存放寬度的字節(jié)數(shù)組
- byte[] hb=new byte[4];//存放高度的字節(jié)數(shù)組
- temp1=new byte[18]; //存放bmp前18個(gè)字節(jié)相關(guān)信息
- bis.read(temp1);//bis.skip(18);//跳過(guò)前18個(gè)byte
- String tp;
- //bis.skip(18);//跳過(guò)18個(gè)字節(jié)
- bis.read(wb);//讀取寬度
- bis.read(hb);//讀取高度
- width=byteToint(wb);
- System.out.println("wb:\""+width+"\"");
- height=byteToint(hb);
- System.out.println("hb:\""+height+"\"");
- map=new int[height][width];//保存圖像的像素點(diǎn)的數(shù)組
- int skip=4-width*3%4;//得到每行要跳過(guò)的數(shù)字(與windows 系統(tǒng)機(jī)制有關(guān))
- //使用調(diào)色板,然后前三個(gè)字節(jié)是顏色分量,最后個(gè)為空所以跳過(guò)
- temp2=new byte[28]; //bis.skip(28);
- bis.read(temp2);//bis.skip(28);
- if(temp1[10]==55)//偏移量為55,此位圖已經(jīng)隱入了信息數(shù)據(jù)
- bis.read();//跳過(guò)1字節(jié)
- for(int i=height-1;i>0;i--)
- {
- for(int j=0;j<width;j++)
- {
- int blue=bis.read(); //讀取顏色的分量
- int green=bis.read();
- int red=bis.read();//
- Color c=new Color(red,green,blue);
- map[i][j]=c.getRGB(); //將RGB分量存入數(shù)組中
- }
- if(skip!=4)
- bis.skip(skip);
-
- }
- } //存放寬度的字節(jié)數(shù)組
- center.setPreferredSize(new Dimension(width,height));
- javax.swing.SwingUtilities.updateComponentTreeUI(center);//這里必須要用updateComponentTreeUI(center)函數(shù)
- //不能用repaint()函數(shù)
- } catch (IOException e) {
- }
- }
- //保存bmp
- public void writeBMP()
- {
- try {
- try (FileOutputStream fos = new FileOutputStream(selectFile)) {
- BufferedOutputStream bos=new BufferedOutputStream(fos);
- bos.write(temp1);// 心如頭部文件
- bos.write(intTobyte(width,4));//寬度
- bos.write(intTobyte(height,4));//高度
- bos.write(temp2);
- int skip=4-width*3%4;//得到每行要跳過(guò)的數(shù)字(與windows 系統(tǒng)機(jī)制有關(guān))
- if(temp1[10]==55)
- bos.write(new byte[1]);
- for(int i=height-1;i>=0;i--)
- {
- for(int j=0;j<width;j++)
- {
- Color c=new Color(map[i][j]);
- int blue=c.getBlue();
- int green=c.getGreen();
- int red=c.getRed();
- bos.write(blue); //寫入之前存放的像素點(diǎn)分量
- bos.write(green);
- bos.write(red);
- }
- if(skip!=4)
- bos.write(new byte[skip]);
- }
- bos.flush();
- }
- } catch (IOException e) {
- }
- }
- //字節(jié)轉(zhuǎn)int
- public static int byteToint(byte b[])
- {
- int t1=(b[3]&0xff)<<24;
- int t2=(b[2]&0xff)<<16;
- int t3=(b[1]&0xff)<<8;
- int t4=b[0]&0xff;
- //System.out.println(b[1]&0xff);//輸出的是一個(gè)整形數(shù)據(jù)
- //在java中,設(shè)計(jì)int和比int位數(shù)來(lái)的小的類型b,如byte,char等,都是先把小類型擴(kuò)展成int再來(lái)運(yùn)算, ??????
- //return( t1<<24)+(t2<<16)+(t3<<8)+t4;//必須加括號(hào)
- return t1+t2+t3+t4;
- }
- public static int byteToint1(byte b[])
- {
-
- int t3=(b[1]&0xff)<<8;
- int t4=b[0]&0xff;
- //System.out.println(b[1]&0xff);//輸出的是一個(gè)整形數(shù)據(jù)
- //在java中,設(shè)計(jì)int和比int位數(shù)來(lái)的小的類型b,如byte,char等,都是先把小類型擴(kuò)展成int再來(lái)運(yùn)算, ??????
- //return( t1<<24)+(t2<<16)+(t3<<8)+t4;//必須加括號(hào)
- return t3+t4;
- }
- //int 轉(zhuǎn)字節(jié)
- public static byte[] intTobyte(int a,int len)
- {
- byte []t=new byte[len];
- t[0]=(byte) ((a&0xff));
- if(len>1)
- t[1]=(byte)((a&0xff00)>>8);
- if(len>2)
- t[2]=(byte)((a&0xff0000)>>16);
- if(len>3)
- t[3]=(byte)((a&0xff000000)>>24);
- return t;
- }
-
- private static void setUIFont(javax.swing.plaf.FontUIResource f) {
- Enumeration<Object> keys = UIManager.getDefaults().keys();
- while (keys.hasMoreElements()) {
- Object key = keys.nextElement();
- Object value = UIManager.get(key);
- if (value instanceof javax.swing.plaf.FontUIResource) {
- UIManager.put(key, f);
- }
- }
- }
- /**
- * LSB處理
- * @author
- * @date 2019年5月3日
- */
- class LSB{
- public boolean hide(boolean flag) {
- FileNameExtensionFilter filter=new FileNameExtensionFilter("文本文檔(*.txt)", "txt");
- JFileChooser fileChosser = new JFileChooser();
- fileChosser.setFileFilter(filter);
- fileChosser.setSelectedFile(new File("密鑰.txt"));
- fileChosser.setCurrentDirectory(new File("\\"));
- String info="";
- System.out.println("temp1【10】:"+temp1[10]);
- temp1[10]+=1;//將位圖數(shù)據(jù)偏移量增1,作為是否隱入數(shù)據(jù)的標(biāo)識(shí),此時(shí)temp1[10]=55;
- System.out.println("temp1【10】:"+temp1[10]);
- if(!flag)
- info=infoJt.getText(); //獲取的隱藏信息
- else{
- String mingwen = "0"+infoJt.getText();
- info=RSAUtil.encrypt(mingwen,keyPair.getPublicKey() ,"UTF-8");
- System.out.println("加密后:"+info);
- int choose=fileChosser.showSaveDialog(null);
- if(choose==JFileChooser.APPROVE_OPTION)
- {
- selectFile=fileChosser.getSelectedFile();
- try {
- FileOutputStream fos=new FileOutputStream(selectFile);
- BufferedOutputStream bos=new BufferedOutputStream(fos);
- byte[] N=keyPair.getPublicKey().getN().toString().getBytes();
- byte[] privateKey=keyPair.getPrivateKey().getA().toString().getBytes();
- String maohao=":";
- byte[] mao=maohao.getBytes();
- length_byte_sum=N.length+privateKey.length+maohao.getBytes().length;
- System.out.println("length_byte_sum"+length_byte_sum);
- byte[] len=String.valueOf(length_byte_sum).getBytes();
- // bos.write(length_byte_sum);
- bos.write(len);//
- bos.write(N);//
- bos.write(mao);//
- bos.write(privateKey);//
- bos.flush();
- fos.close();
- } catch (IOException e) {
-
- }
-
- }else{
- return false;
- }
-
-
- }
-
- infoJt.setText("保存成功!");
- System.out.println("隱藏信息:"+info);
- char[] infoChs=info.toCharArray(); //將隱藏信息轉(zhuǎn)成字符數(shù)組
- System.out.println("隱藏信息長(zhǎng)度"+infoChs.length);
- int index=0,endIndex=0;
- String str;
- byte[] infoBins=new byte[infoChs.length*16];//隱藏信息的字符長(zhǎng)度
- // 二進(jìn)制字符串 一個(gè)字符兩個(gè)字節(jié) 轉(zhuǎn)成16位
- char[] wordBins=new char[16];
- // 字節(jié)二進(jìn)制字符串
- //將每個(gè)字節(jié)隱藏的信
- for(int i=0;i<infoChs.length;i++) {
- str=intToWordBinaryString((int)infoChs[i]);
- //把int轉(zhuǎn)成二進(jìn)制字符串 7 111
- //把每個(gè)字符都轉(zhuǎn)成對(duì)應(yīng)的二進(jìn)制字符串
- // System.out.print(str+" ");
- str=new StringBuilder(str).reverse().toString();
- // System.out.print(str+" ");
- //reverse 逆序轉(zhuǎn)換 123 321
- wordBins=str.toCharArray();
- for(int j=0;j<16;j++) {
- // System.out.print(wordBins[j]);
-
- infoBins[index++]=(byte)(wordBins[j]-'0');
- //反向加密
- }
- // System.out.println();
- }
-
- //隱藏信息
- index=0;
- for(int i=height-1;i>0;i--) //hang
- for(int j=0;j<width;j++) //lie
- { //infoBins 已經(jīng)將信息轉(zhuǎn)換成字節(jié)反向的二進(jìn)制字符串
- if(index<infoBins.length) {
-
- map[i][j]=map[i][j]&0xfffffffe; //int 4個(gè)字節(jié)
- //數(shù)據(jù)末尾位清洗為0
- //如果infoBins的位為1則將map對(duì)應(yīng)像素點(diǎn)加1
- if(infoBins[index]==1) {
- map[i][j]+=1;
- }
- // System.out.print(map[i][j]+" ");
- index++;
- }
- else
- {
- map[i][j]=map[i][j]&0xfffffffe;//結(jié)束標(biāo)記,一個(gè)字的最低位為0
- endIndex++;
- if(endIndex>=16)
- return true;
- }
- }
-
- return false;
- }
- public String show(boolean flag) throws UnsupportedEncodingException {
- byte temp[] = null;
- FileNameExtensionFilter filter=new FileNameExtensionFilter("文本文檔(*.txt)", "txt");
- JFileChooser fileChosser = new JFileChooser();
- fileChosser.setFileFilter(filter);
- fileChosser.setCurrentDirectory(new File("\\"));
- String info="";
- byte[] wordBins=new byte[16];
- int index=0;
- String wordStr="";
- int wordInt;
- outer:for(int i=height-1;i>=0;i--) {
- for(int j=0;j<width;j++) {
- wordBins[index++]=(byte)(map[i][j]&0x00000001);
- if(index>=16) {
- for(int k=15;k>=0;k--) {
- wordStr+=wordBins[k];
- }
- wordInt=Integer.parseInt(wordStr,2);
- if(wordInt!=0) {
- info+=(char)wordInt;
- }else {
- break outer;
- }
- index=0;wordStr="";
- }
- }
- }
- String infor=info;
- String result=null;
- if(!flag)
- result = infor;
- else
- {
- int choose=fileChosser.showOpenDialog(null);
- if(choose==JFileChooser.APPROVE_OPTION)//點(diǎn)擊的是確定按鈕
- {
- selectFile=fileChosser.getSelectedFile();
- try {
- FileInputStream fis=new FileInputStream(selectFile); //選擇文件
- BufferedInputStream bis=new BufferedInputStream(fis); //輸入的緩沖區(qū)
- byte[] wb=new byte[4];//存放寬度的字節(jié)數(shù)組
- bis.read(wb);
- System.out.println("wb:::"+ new String (wb));
- int len=Integer.parseInt( new String (wb) );
- temp =new byte[len];
- bis.read(temp);
- bis.close();
- String str= new String (temp);
- String[] sub=str.split(":");
- System.out.println("sub[0]"+sub[0]);
- System.out.println("sub[1]"+sub[1]);
- BigInteger n=new BigInteger(sub[0]);
- BigInteger a=new BigInteger(sub[1]);
- PrivateKey p =new PrivateKey( n,a);
- result=RSAUtil.decrypt(infor, p,"UTF-8");
- } catch (Exception e) {
- }
-
- }
-
- }
- return result;
- }
- private String intToWordBinaryString(int i) {
- StringBuilder sb = new StringBuilder(Integer.toBinaryString(i));
- while (sb.length() < 16) {
- sb.insert(0, "0");
- }
- return sb.toString();
- }
- }
- /**
- * 顯示面板
- *
- *
- */
- class MyPanel extends JPanel{
- private static final long serialVersionUID = 1L;
- public void paint(Graphics g) {
- super.paint(g);
- if(map!=null)
- {
- for(int i=0;i<map.length;i++)
- {
- for(int j=0;j<map[i].length;j++)
- {
- g.setColor(new Color(map[i][j]));
- g.drawLine(j+200, i, j+200, i);
- }
- }
- }
- }
- }
- class MyListener implements ActionListener{
- JFileChooser fileChosser;
- //文件選擇控件
- MyListener()
- {
- FileNameExtensionFilter filter=new FileNameExtensionFilter("24位位圖(*.bmp)", "bmp");
- fileChosser=new JFileChooser();
- fileChosser.setFileFilter(filter);
- fileChosser.setCurrentDirectory(new File("\\"));
- }
- public void actionPerformed(ActionEvent e) {
- JMenuItem jmi = (JMenuItem) e.getSource();
- if(jmi==open)//選擇的是打開(kāi)
- {
- open_flag=true;
- int choose=fileChosser.showOpenDialog(null);
- if(choose==JFileChooser.APPROVE_OPTION)//點(diǎn)擊的是確定按鈕
- {
- selectFile=fileChosser.getSelectedFile();
- readBMP();
- infoJt.setText("圖片打開(kāi)成功!\n");
- if(temp1[10]==54) {
- infoJt.append("最多可嵌入"+height*width/8+"個(gè)字節(jié)的信息!\n");
- }else if(temp1[10]==55) {
- infoJt.append("此圖片已經(jīng)隱入有信息!");
- }
- }
- }
- else if(jmi==save)//選擇的是保存
- {
- if(open_flag){
- int choose=fileChosser.showSaveDialog(null);
- if(choose==JFileChooser.APPROVE_OPTION)
- {
- selectFile=fileChosser.getSelectedFile();
- writeBMP();
- infoJt.setText("保存成功!");
- }
- }else{
- infoJt.setText("請(qǐng)先打開(kāi)圖片!");
- }
-
- }
- else if(jmi==hide) {
- if(open_flag){
- if(new LSB().hide(false)) {
- infoJt.setText("信息隱入成功!");
- }else{
- infoJt.setText("信息隱入出現(xiàn)不確定問(wèn)題!");
- }
- }else{
- infoJt.setText("請(qǐng)先打開(kāi)圖片!");
- }
- }
- else if(jmi==hide_rsa) {
- if(open_flag){
- if(new LSB().hide(true)) {
- infoJt.setText("信息隱入成功(RSA加密)!");
- }else{
- infoJt.setText("信息隱入出現(xiàn)不確定問(wèn)題!");
- }
- }else{
- infoJt.setText("請(qǐng)先打開(kāi)圖片!");
- }
- }
- else if(jmi==show) {
- if(open_flag){
- try {
- String info=new LSB().show(false);
- infoJt.setText("隱入的信息內(nèi)容\n");
- infoJt.append(info);
- } catch (UnsupportedEncodingException ex) {
- Logger.getLogger(_LSB_BMP.class.getName()).log(Level.SEVERE, null, ex);
- }
- }else{
- infoJt.setText("請(qǐng)先打開(kāi)圖片!");
- }
- }
- else if(jmi==show_rsa) {
- if(open_flag){
- try {
- String info=new LSB().show(true);
- infoJt.setText("隱入的信息內(nèi)容(RSA解密!)\n");
- infoJt.append(info);
- } catch (UnsupportedEncodingException ex) {
- Logger.getLogger(_LSB_BMP.class.getName()).log(Level.SEVERE, null, ex);
- }
- }else{
- infoJt.setText("請(qǐng)先打開(kāi)圖片!");
- }
- }
- }
- }
- public static void main(String[] args) {
- new _LSB_BMP();
- }
- }
復(fù)制代碼
0.png (3.97 KB, 下載次數(shù): 50)
下載附件
2019-7-24 04:19 上傳
全部資料51hei下載地址:
LSB,RSA的圖片隱藏技術(shù).zip
(41.2 KB, 下載次數(shù): 11)
2019-7-23 18:49 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|