Guidance
指路人
g.yi.org
software / rapidq / Examples / Security / Hide file in bmp / $_SoftWareV1.bas

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
' $-Software.bas for RapidQ
' Coded by Gérald VERDIER - BinoclaR (°-°) software
' november 2003
' email : gerald.verdier@club-internet.fr
' PURPOSE : Hide a file in a BMP image, possibility to see it (BMP+file) in PAINT simply (for exemple)
'           extract the file from the .BMP and save it on your HDD and recover the image too
' with this software you can keep your confidential datas in security into a .BMP
' you can share your secret files on internet
' the size of the file to incorporate musn't be over 20% or 30% of the image to complete (seem suspicious)
'
     $INCLUDE "rapidq.inc"


     DIM Nfile AS QFILESTREAM
     DIM MemF AS QMEMORYSTREAM
     DIM SaveF AS QFILESTREAM
     DIM mem AS QMEMORYSTREAM
     DIM bmp AS QBITMAP
     DIM bmpS AS QBITMAP

     DIM SF_f$ AS STRING
     DIM F_f$ AS STRING
     DIM nbCar AS INTEGER
     DIM sz AS INTEGER
     DIM file$ AS STRING
     DIM Sfile$ AS STRING
     DIM nameF$ AS STRING
     DIM dh AS INTEGER
     DIM dw AS INTEGER
     dh=25'bmp.height -  screen.height
     dw=25'bmp.width - screen.width
     DIM Source AS QRECT
     DIM Destination AS QRECT
     DEFINT bmpTop = 0, bmpLeft = 0, Busy = 0
     DEFSNG Zoom = 1
     DIM OpenBmp AS QOPENDIALOG
     DIM OpenBmpD AS QOPENDIALOG
     DIM OpenAllS AS QOPENDIALOG
     DIM Font AS QFONT
     Font.Name = "Courrier new"
     Font.Size = 10


     DECLARE SUB decod
     DECLARE SUB OpenS
     DECLARE SUB OpenF
     DECLARE SUB FreeF
     DECLARE SUB quit
     DECLARE SUB createF
     DECLARE SUB formFocus
     DECLARE SUB paint
     DECLARE SUB About
     DECLARE SUB Help
     DECLARE SUB PaintSZ
     DECLARE SUB OnForm_KeyDown (Key AS BYTE, Shift AS INTEGER)


     CREATE helpForm AS QFORM
      CAPTION = "Help"
      COLOR =&hd0d058
      font = font
      Width = 550
      Height = 300
      cursor = crHand
      borderStyle = bsToolWindow
      visible = 0
      Center
     END CREATE

     CREATE form AS QFORM
      CAPTION = "$-Software - Gérald VERDIER"
      Width = screen.width
      Height = screen.height - 80
      font = font
      Center
      OnResize = paint
      OnKeyDown = OnForm_KeyDown
      OnClick = paint
      CREATE panel AS QPANEL
       top = 5
       left = 5
       height = form.height - 105
       width = form.width - 20
       BevelOuter =  bvLowered
       CREATE canvas AS QCANVAS
        top = 5
        left = 5
        height = form.height - 100
        width = form.width - 100
        cursor = crCross
        onClick = paint
       END CREATE
      END CREATE
      CREATE menu AS QMAINMENU
       CREATE menufile AS QMENUITEM
        CAPTION = "&Files"
        CREATE menuloadBmp AS QMENUITEM
         CAPTION = "&Bmp to complete"
         onclick = OpenF
        END CREATE
        CREATE menuloadBmpS AS QMENUITEM
         CAPTION = "&File to incorporate"
         onclick = OpenS
        END CREATE
        CREATE menucreate AS QMENUITEM
         CAPTION = "&Create file_$ "
         onclick = createF
        END CREATE
        CREATE menusearch AS QMENUITEM
         CAPTION = "&Decode $_file"
         onclick = decod
        END CREATE
        CREATE menuexit AS QMENUITEM
         CAPTION = "&Exit"
         onclick = quit
        END CREATE
       END CREATE
       CREATE menuhelp AS QMENUITEM
        CAPTION = "&Help"
        CREATE menuAbout AS QMENUITEM
         CAPTION = "&About"
         onclick = About
        END CREATE
        CREATE menuHlp AS QMENUITEM
         CAPTION = "&Help"
         onclick = Help
        END CREATE
       END CREATE
       CREATE menuempty AS QMENUITEM
        CAPTION = "                                                                                          *"
       END CREATE
       CREATE menuKey AS QMENUITEM
        CAPTION = "Arrow keys to move picture/+ or - to resize  *"
       END CREATE
      END CREATE
      CREATE StatusBar AS QSTATUSBAR
       AddPanels "Image to complete : ","File to incorporate : "
       Panel(0).Width = screen.width/2
       Panel(0).Alignment = taCenter
       Panel(1).Alignment = taCenter
      END CREATE
     END CREATE


     form.SHOWMODAL

'------------------------CODE--------------------
     SUB OpenF    '===========file to complete========

      OpenBmp.Filter = "Bitmap(*.bmp)|*.bmp"
      OpenBmp.FilterIndex = 1
      OpenBmp.CAPTION = "Select File BMP"
      OpenBmp.FileName = ""
      IF OpenBmp.EXECUTE THEN
       ff$=""
       f$ = OpenBmp.FileName
       Nfile.OPEN(f$, FmOpenRead)
       FOR i = LEN(f$) TO 1 STEP -1
        a$ = MID$(f$,i,1)
        IF a$ = "\" THEN EXIT FOR
        ff$ = ff$+a$
       NEXT i
       file$ = reverse$(ff$)
      END IF
      IF f$ = "" THEN
       FreeF
      END IF
      sz = Nfile.Size
      MemF.CopyFrom(NFile,sz )
      MemF.Position = 0
      NFile.Position = 0
      F_f$ = MemF.ReadStr(sz)
      NFile.CLOSE
      Bmp.BMP = file$
      form.CAPTION = "image/BMP : " + file$
      canvas.repaint
      Canvas.Draw (0,0,bmp.Bmp)
      StatusBar.Panel(0).CAPTION = "Image in memory : "+file$+" - "+STR$(sz)+ " bytes"+ " - "+STR$(bmp.width)+"x"+STR$(bmp.height)+" to complete"

     END SUB
' ------------------
     SUB OpenS    '============file to incorporate=========

      OpenAllS.Filter = "All files(*.*)|*.*"
      OpenAllS.FilterIndex = 1
      OpenAllS.CAPTION = "Select all files"
      OpenAllS.FileName = ""
      IF OpenAllS.EXECUTE THEN
       ff$=""
       f$ = OpenAllS.FileName
       Nfile.OPEN(f$, FmOpenRead)
       FOR i = LEN(f$) TO 1 STEP -1
        a$ = MID$(f$,i,1)
        IF a$ = "\" THEN EXIT FOR
        ff$ = ff$+a$
       NEXT i
       Sfile$ = reverse$(ff$)
      END IF
      IF f$ = "" THEN
       FreeF
      END IF

      sz = Nfile.Size
      Mem.CopyFrom(NFile,sz )
      Mem.Position = 0
      NFile.Position = 0
      SF_f$ = Mem.ReadStr(sz)
      NFile.CLOSE
    '
      form.CAPTION = "File : " + Sfile$
      StatusBar.Panel(1).CAPTION = "File in memory : "+sfile$+" - "+STR$(sz)+ " bytes"+ " - "+ " to incorporate"
     END SUB
' ------------------
     SUB createF    '=================create $ file BMP+file===========================
      nameF$=sfile$+SPACE$(255-LEN(sfile$))'maximum length for a file name
      filext$=file$-RIGHT$(file$,4)
      saveF.OPEN(filext$+"$.bmp", fmCreate)
      saveF.write(F_f$)
      saveF.writeLine(nameF$)
      saveF.write(SF_f$)
      saveF.CLOSE
      SHOWMESSAGE filext$+"$.bmp"+" created"
      FreeF
     END SUB
' ------------------
     SUB decod    '==============decoding file incorporated in image completed===========
      r=0
      OpenBmpd.Filter = "Bitmap$(*.bmp)|*.bmp"
      OpenBmpd.FilterIndex = 1
      OpenBmpd.CAPTION = "Select File BMP$"
      OpenBmpd.FileName = ""
      IF OpenBmpD.EXECUTE THEN
       ff$=""
       d$ = OpenBmpd.FileName
       Nfile.OPEN(d$, FmOpenRead)
       FOR i = LEN(d$) TO 1 STEP -1
        a$ = MID$(d$,i,1)
        IF a$ = "\" THEN EXIT FOR
        ff$ = ff$+a$
       NEXT i
       file$ = reverse$(ff$)
      END IF
      IF d$ = "" THEN
       FreeF
      END IF
      sz = Nfile.Size
      MemF.CopyFrom(NFile,sz )
      MemF.Position = 0
      NFile.Position = 0
      F_f$ = MemF.ReadStr(sz)
      NFile.CLOSE
      MemF.position = 2
      fsz$=MemF.readStr(4)
      FOR i = LEN(fsz$) TO 1 STEP -1
       t$ = MID$(fsz$,i,1)
       c = ASC(t$)
       IF t$ > CHR$(0) THEN
        c$ = c$ + RIGHT$(HEX$(c),2)
        h$ = h$ + t$
       END IF
      NEXT i
      r=VAL(CONVBASE$(c$,16,10))
      difsz=sz-r
      IF sz = r THEN
       SHOWMESSAGE "no file inside - select a BMP$"
       EXIT SUB
      END IF
      MemF.position = r
      nameFs$=MemF.readLine
      MemF.position = r+257 '*************************** 'don't forget the end of line
      logs$=MemF.readStr(difsz-257)'********************
      saveF.OPEN("$"+RTRIM$(nameFs$), fmCreate)
      saveF.write(logS$)
      saveF.CLOSE
      FreeF
      Nfile.OPEN(d$, FmOpenRead)
      sz = Nfile.Size
      MemF.CopyFrom(NFile,sz)
      MemF.Position = 0
      NFile.Position = 0
      F_f$ = MemF.ReadStr(sz-difsz)
      NFile.CLOSE
      Bmp.BMP = file$
      form.CAPTION = "image/BMP : $" + file$
      paint
      saveF.OPEN("$"+(File$), fmCreate)
      saveF.write(F_f$)
      saveF.CLOSE
      FreeF
      SHOWMESSAGE "$"+RTRIM$(nameFs$)+ " hidden in BMP, recreated on your HDD ..."+CHR$(13) + "$"+File$ + " rebuilt as ordinary BMP file"
      StatusBar.Panel(1).CAPTION = " - $"+RTRIM$(nameFs$)+" / extracted file size "+STR$(difsz-257)
      StatusBar.Panel(0).CAPTION = "Recovered BMP : $"+file$+" - "+STR$(sz-difsz)+ " bytes"+ " - "+STR$(bmp.width)+"x"+STR$(bmp.height)+" Ok! to read"

      F_f$=""
     END SUB

' ------------------
     SUB paint
      canvas.repaint
      Canvas.Draw (0,0,bmp.Bmp)
     END SUB
' ------------------
     SUB PaintSZ 'code by Jacques Philippe
      canvas.repaint
      WITH Source
       .Top = bmpTop       ' Increase to scroll Left
       .Left = bmpLeft     ' Increase to Scroll Up
       .Right = (Canvas.Width * Zoom) + bmpLeft
       .Bottom = (Canvas.Height * Zoom) + bmpTop
      END WITH
      WITH Destination
       .Top = 0
       .Left = 0
       .Right = Canvas.Width
       .Bottom = Canvas.Height
      END WITH
      Canvas.CopyRect(Destination, BMP, Source)
     END SUB
' ------------------
     SUB OnForm_KeyDown (Key AS BYTE, Shift AS INTEGER) 'code by Jacques Philippe
      IF Busy = 1 THEN EXIT SUB
      Busy = 1
      SELECT CASE Key
      CASE 37   ' Left
       Form.CAPTION = file$ + " - Last Key Hit : LEFT " & "    Zoom = " & STR$(Zoom)
       bmpLeft = bmpLeft - dw
      CASE 38   ' Up
       Form.CAPTION = file$ + " - Last Key Hit : UP " & "    Zoom = " & STR$(Zoom)
       bmpTop = bmpTop - dh
      CASE 39   ' Right
       Form.CAPTION = file$ + " - Last Key Hit : RIGHT " & "    Zoom = " & STR$(Zoom)
       bmpLeft = bmpLeft + dw
      CASE 40   ' Down
       Form.CAPTION = file$ + " - Last Key Hit : DOWN " & "    Zoom = " & STR$(Zoom)
       bmpTop = bmpTop + dh
      CASE 107   ' ZOOM +
       Zoom = Zoom / 2
       Form.CAPTION = file$ + " - Last Key Hit : ZOOM +  " & "    Zoom x " & STR$((Zoom/Zoom)/Zoom)
      CASE 109   ' ZOOM -
       Zoom = Zoom * 2
       Form.CAPTION = file$ + " - Last Key Hit : ZOOM -  " & "    Zoom x " & STR$((Zoom/Zoom)/Zoom)
      CASE ELSE
       Busy = 0
       EXIT SUB
      END SELECT
      IF bmpTop < 0 THEN BmpTop = 0
      IF bmpTop + form.height = BMP.height THEN   BmpTop = 0
      IF bmpLeft < 0 THEN bmpLeft = 0
      IF bmpLeft + form.width = BMP.width THEN   bmpLeft =0
      PaintSZ
      Busy = 0
     END SUB
' ------------------
     SUB FreeF
      MemF.CLOSE
      filext$=""
     END SUB
' ------------------
     SUB quit
      form.CLOSE
      application.terminate
     END SUB
' ------------------
     SUB mess
      SHOWMESSAGE "Load a file !"
      OpenF
     END SUB

' ------------------Menu Help---------------------------
     SUB About
      SHOWMESSAGE "_____By   Gérald  VERDIER_____"+CHR$(13)+_
       "______Hide a file  in  a BMP_____"+CHR$(13)+_
       "_gerald.verdier@club-internet.fr_"+CHR$(13)+_
       "___________________________"
     END SUB
' ------------------
     SUB Help
      helpForm.visible = 1
      helpForm.show

      helpForm.textOut (10,10,"This software hide a file in a BMP image, width possibility to see it (BMP+file) in PAINT simply" , &hff0000,-1)
      helpForm.textOut (10,30,"(for exemple), and extract the file from the .BMP, save it on your HDD and recover the image too", &hff0000,-1)
      helpForm.textOut (10,50,"With this software you can keep your confidential datas in security into a $.BMP, or you can share", &hff0000,-1)
      helpForm.textOut (10,70,"your secret files on internet ... for the fun only of course.   Mix your RQ code, your music ... ", &hff0000,-1)
      helpForm.textOut (10,90,"The size of the file to incorporate musn't be over 20% or 30% of the BMP to complete because the", &hff0000,-1)
      helpForm.textOut (10,110,"result of the mix could seem suspicious ... hum? for spies only ... (a small one in a big one)", &hff0000,-1)
      helpForm.textOut (10,150,"    - 1)Open a (name.BMP) file to complete - 2)Open another file (all files are available ...)", &hff0000,-1)
      helpForm.textOut (10,170,"    - 3)Create a file (name$.BMP) - 4) To test, open your created (name$.BMP) file", &hff0000,-1)
      helpForm.textOut (10,190,"    - 5)Install the program on your friend's computer to send and decode $.BMP with them", &hff0000,-1)

      helpForm.textOut (10,220,"FILE CREATED : name$.BMP (completed with your file) to decode", &hff0000,-1)
      helpForm.textOut (10,240,"FILES RECOVERED : $name (your file recreated), $name$.BMP (same as your name.BMP file)", &hff0000,-1)

      helpForm.textOut (20,260,"____________________Program developped with RapidQ (William Yu)___________________ ", &hff00ff,-1)
      _
      END SUB

掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2019-4-25  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-12-04 05:14:36