Giter Club home page Giter Club logo

streams's Introduction

streams

This is a tiny implementation of streams in C++ for:

  • Byte serialization
  • Zlib compression (based on richgel999's miniz)
  • Zstandard compression (based on facebook's zstd)
  • AES encryption (based on kokke's tiny-AES-c)

Examples

Beside the examples below, you may want to check test files in the tests directory.

Byte serialization

oo::obstream o;
o << int32_t(1234567890);
o << uint64_t(1000000000000000);

std::vector<uint8_t> encoded;
o >> encoded;

oo::ibstream i;
i << encoded;

int32_t i32;
i >> i32;

uint64_t u64;
i >> u64;

Zlib compression

oo::ozlstream o;
o << int32_t(1234567890);
o << uint64_t(1000000000000000);

std::vector<uint8_t> encoded;
o >> encoded;

oo::izlstream i;
i << encoded;

int32_t i32;
i >> i32;

uint64_t u64;
i >> u64;

Zstdandard compression

oo::ozsstream o;
o << int32_t(1234567890);
o << uint64_t(1000000000000000);

std::vector<uint8_t> encoded;
o >> encoded;

oo::izsstream i;
i << encoded;

int32_t i32;
i >> i32;

uint64_t u64;
i >> u64;

AES encryption

const uint8_t key[] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c};
const uint8_t iv[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
                          
oo::oastream o(key, iv);
o << int32_t(1234567890);
o << uint64_t(1000000000000000);

std::vector<uint8_t> encoded;
o >> encoded;

oo::iastream i(key, iv);
i << encoded;

int32_t i32;
i >> i32;

uint64_t u64;
i >> u64;

Requirements

This library requires a C++17 compiler and standard library.

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.