Giter Club home page Giter Club logo

securestream's Introduction

SecureStream

Provide CTR based simple AES encryption/decryption stream.

Using

Basic methods

  // This method same as MemoryStream class methods. //
  CryptoMemoryStream.Write
  CryptoMemoryStream.Read
  
  // Encrypts and writes bytes to the stream. //
  CryptoMemoryStream.Encrypt
  
  // Decrypts and reading bytes from stream. //
  CryptoMemoryStream.Decrypt

Notes

These methods do not reuse the nonce used in the CTR algorithm. That is, the result of encrypting all the bytes at once by the Write method differs from the result of encrypting the bytes by dividing them many times.

Encryption

  byte[] datas = new byte[] {0x00, 0x00, 0x00, 0x00};
  byte[] buffer = new byte[datas.Length];
  
  // Encrypt bytes //
  CryptoMemoryStream.Encrypt(datas, 0, datas.Length);
  
  // Reading encrypted bytes //
  // The CTR-based AES encryption algorithm has the same length as the original data length and the encrypted data. //
  // 0x00, 0x00, 0x00, 0x00 => 0x??, 0x??, 0x??, 0x??
  CryptoMemoryStream.Read(buffer, 0, buffer.Length);

Decryption

  byte[] encryptedDatas = new byte[] {0x??, 0x??, 0x??, 0x??};
  byte[] buffer = new byte[encryptedDatas.Length];
  
  // Decrypt bytes //
  CryptoMemoryStream.Write(encryptedDatas, 0, encryptedDatas.Length);
  
  // Reading dencrypted bytes //
  CryptoMemoryStream.Decrypt(buffer, 0, buffer.Length);

securestream's People

Contributors

10sa avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.