GithubHelp home page GithubHelp logo

sorcerykid / cipher Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 6 KB

Simple Cipher is a lightweight and portable cryptography library for Minetest.

Awk 9.32% Lua 90.68%
algorithm hashing library xtea-cipher lua

cipher's Introduction

Simple Cipher Mod v1.1
By Leslie E. Krause

Simple Cipher is a lightweight and portable cryptography library providing a minimal 
degree of security for non mission-critical data (e.g. unique, non-guessable URLs).

Also included is a pure Lua-adaptation of XTEA, a public domain block-cipher algorithm
designed by Needham and Wheeler in 1997.

The following library functions are available:

   cipher.get_checksum( str, method )
   Calculates and returns the numeric hash of the string using one of these methods:
    o "fletcher64" for the Fletcher-64 algorithm
    o "fletcher32" for the Fletcher-32 algorithm
    o "fletcher16" for the Fletcher-16 algorithm
    o "adler32" for the Adler-32 algorithm (default)

  cipher.tokenize( hash )
  Given a numeric hash, this function generates and returns a token consisting only of 
  letters in the alphabet soup. This is primary useful for generating short-URLs, in
  which the hash corresponds to a unique key within a database of site redirects.

  cipher.generate_key( username, password )
  Generates and returns a 128-bit public/private key pair for use with either of the
  cryptography functions described below. This key is intended only for encrpytion and
  decryption, and should NEVER be shared under any circumstances. If a password is not 
  provided, then the value of `cipher.password` will be used by default.

  cipher.encrypt( num, str, key )
  Encrypts the string using the XTEA block-cipher and returns the ciphertext. The key 
  should be generated by `cipher.generate_key`, and an appropriate number of rounds 
  chosen to mitigate against attacks (32 or more is recommended, 64 is maximum).

  cipher.decrypt( str, key )
  Decrypts the string that was previously encrypted by `cipher.encrypt()` with the same
  key generated by `cipher.generate_key`. The enrypted string will be checked both for 
  proper length and valid header prior to decryption.

  cipher.encrypt_to_base64( str, username )
  This is a convenience function for encryption of a string with just a username. It
  returns a Base-64 string representation of the ciphertext.

  cipher.decrypt_from_base64( str, username )
  This is the inverse of `cipher.encrypt_to_base64`, and therefore expects a Base-64
  string representation of the ciphertext as well as the original username.

Before you begin, it is important that you customize the alphabet soup that will be used 
by the tokenizer. Likewise, if you intend to use the XTEA block-cipher, then a password
needs to be set. Both variables can be found at the head of the `init.lua` file.


Dependencies
----------------------

Bitwise Operators Mod (required)
  https://bitbucket.org/sorcerykid/bitwise

Source Code License
----------------------

MIT License

Copyright (c) 2016-2020, Leslie E. Krause.

Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

For more details:
https://opensource.org/licenses/MIT

cipher's People

Contributors

sorcerykid avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

2188886665

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.