GithubHelp home page GithubHelp logo

asaaki / bevy_assets_bundler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hanabi1224/bevy_assets_bundler

0.0 1.0 0.0 273 KB

Assets Bundler for bevy, with encryption support

License: MIT License

Rust 100.00%

bevy_assets_bundler's Introduction

Bevy Assets Bundler

github action codecov dependency status loc License

crates.io docs.rs

Assets Bundler for bevy, with content encryption support. Current archive format is tar and encryption algorithm is AES

Features

  • Bundle asset folder into a single assets.bin file
  • Asset encryption with custom key
  • Asset file names encoding (base58 when ecryption is off, AES+base58 otherwise)
  • One simple switch to turn off bundling on debug build
# Cargo.toml
[dependencies]
bevy = "0.9"
bevy_assets_bundler = "0.5"

[build-dependencies]
bevy_assets_bundler = "0.5"

You can generate a random key with this playground

use bevy_assets_bundler::*;

// build.rs
// encryption key: [u8; 16] array
// make sure the key is consistent between build.rs and main.rs
// or follow the example code to share code between build.rs and main.rs
fn main() {
    let key = [30, 168, 132, 180, 250, 203, 124, 96, 221, 206, 64, 239, 102, 20, 139, 79];
    let mut options = AssetBundlingOptions::default();
    options.set_encryption_key(key);
    options.encode_file_names = true;
    options.enabled_on_debug_build = true;
    AssetBundler::from(options).build();//.unwrap();
}
use bevy_assets_bundler::*;
use bevy::{asset::AssetPlugin, prelude::*};

fn main() {
    // encryption key: [u8; 16] array
    // make sure the key is consistent between build.rs and main.rs
    // or follow the example code to share code between build.rs and main.rs
    let key = [30, 168, 132, 180, 250, 203, 124, 96, 221, 206, 64, 239, 102, 20, 139, 79];
    let mut options = AssetBundlingOptions::default();
    options.set_encryption_key(key);
    options.encode_file_names = true;
    options.enabled_on_debug_build = true;

    App::new()
        .add_plugins(
            DefaultPlugins
                .build()
                .add_before::<bevy::asset::AssetPlugin, _>(BundledAssetIoPlugin::from(
                    options,
                )),
        )
        .add_startup_system(setup)
        .run();
}

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
}
#[derive(Debug, Clone)]
pub struct AssetBundlingOptions {
    #[cfg(feature = "encryption")]
    pub encryption_on: bool,
    #[cfg(feature = "encryption")]
    pub encryption_key: Option<[u8; 16]>,
    #[cfg(feature = "compression")]
    pub enable_compression: bool,
    pub enabled_on_debug_build: bool,
    pub encode_file_names: bool,
    pub asset_bundle_name: String,
}

TODO

  • Compression
  • More encryption algorithms

Bevy Version Supported

bevy bevy_assets_bundler
main bevy_main
0.10 0.6
0.9 0.5
0.8 0.4
0.7 0.3
0.6 0.2
0.5 0.1

Examples

Check out example and E2E test

To run example: cargo run -p example

go to target/release folder, now you can move example(.exe) and assets.bin to some other place and run, just keep the relative path between them.

Disclaimer

The encryption mechnism this library provides does not protect your assets from ALL kinds of reverse engineering as long as the game executable and the assets bundle are distributed to end users.

MIT

bevy_assets_bundler's People

Contributors

hanabi1224 avatar snorrwe avatar jarkonik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.