gfxgfxFreeBASIC Games Directory Forumgfxgfx
gfx gfx
gfx
Welcome, Guest. Please login or register. June 19, 2013, 03:52:08 PM

Login with username, password and session length
11.5.2013 - Added a webpage for the latest FBGD competition.

13.3.2013 - Members registrations temporary disabled. For all membership requests, please email me: lachie13@yahoo.com

30.11.2012 - The ninth issue of BASIC Gaming is out! Read it here: http://games.freebasic.net/forum/index.php?topic=560.0

22.11.2012 - Be sure to check our currently running annual FBGD game making competition. This year's theme is SEASONS OF THE YEAR, 300 $ first place prize, and the competition runs till 18th of February. Link: http://games.freebasic.net/forum/index.php?topic=559.0
gfx
gfx
*
gfxgfx
gfxgfx gfxgfx
gfxgfx Home Help Search Login Register   gfxgfx
gfx gfx
gfx
  Show Posts
Pages: [1]
1  FreeBASIC Game Development / Programming / Re: FB.Packer - simple package manager on: May 30, 2008, 02:57:40 AM
latest  (updated, bug fixed) version can be found at: http://code.google.com/p/fbpacker/
2  FreeBASIC Game Development / Programming / FB.Packer - simple package manager on: May 27, 2008, 09:47:23 PM
originally posted at FreeBASIC Forums

I've wrote simple package manager which supports encryption, it's called Packer and it's placed inside FB namespace (and thats why it's called FB.Packer)...

anyway, you can download code from here: http://krcko.haragei.org/fb/fbpacker.zip

this is how you use it to create package:
#include "fbpacker.bi"

Dim As FB.Packer package

package.AddFile "txt file", "readme.txt"  ' include readme.txt in package
package.AddFile "bmp file", "background.bmp" ' include background.bmp
' ...
package.Save "data.pck", "ultra secure password"
and this is how you unpack it:
Dim As FB.Packer package

package.Load "data.pck", "ultra secure password"

package.ExtractFile "txt file", "extracted.txt" ' unpack to extracted.txt
package.ExtractFile "bmp file", "extracted.bmp" ' unpack to extracted.bmp
simple, isn't it?


FB.Packer methods:

Sub Packer.AddFile(Name As String, Filename As String)
 -- Adds new file to package, data is read from file. If item with specified Name already exists it will be overwritten

Sub Packer.AddFile(Name As String, pData As UByte Pointer, length As Integer)
 -- Adds new file to package, data is read from memory. If item with specified Name already exists it will be overwritten

Sub Packer.ExtractFile(Name As String, OutputFile As String)
 -- Extracts file from package to file

Sub Packer.ExtractFile(Name As String, pData As UByte Pointer, ByRef length As Integer)
 -- Extracts file from package to memory

Sub Packer.Remove(Name As String)
 -- Removes file from package

Sub Packer.Clear
 -- Removes all files from package

Sub Packer.Save(Filename As String, Password As String)
 -- Writes package to file and encrypts data using provided password

Sub Packer.Load(Filename As String, Password As String)
 -- Loads package from file and decrypts data using provided password


FB.Packer properties:

Encrypt   As CryptFunction
 -- sets function used for encryption (defaults to RC4 algorithm which is included in fbpacker.bi)

Decrypt As CryptFunction
 -- sets function used for decryption (defaults to RC4 algorithm which is included in fbpacker.bi)

CryptFunction is declared as:
Type CryptFunction As Sub(ptrData As UByte Pointer, length As Integer, password As String)

i might add support for compression/decompression tomorow...
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
Cerberus design by Bloc
Valid XHTML 1.0! Valid CSS!
gfx
gfxgfx gfxgfx