Skip to content

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

Notifications You must be signed in to change notification settings

sorcerykid/cipher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published