Coder Social home page Coder Social logo

haolly / lua-crypt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jprjr/lua-crypt

0.0 2.0 0.0 23 KB

A crypt(3)-style module for Lua. Brings its own implementations, entirely independent of your local libc

License: MIT License

Makefile 1.36% Lua 11.04% C 87.60%

lua-crypt's Introduction

lua-crypt

A small Lua module for encrypting passwords

Usage:

  • local crypt = require'crypt'

Initializes a new crypt object.

Object has the following methods:

  • hash, err = crypt.encrypt(method,key,salt)
    • Encrypts key with given method and salt
    • method is one of:
      • md5
      • apr1
      • sha
      • ssha
      • sha256
      • sha512
    • salt is optional and will be randomly generated if not provided (except sha - don't encrypt new passwords with sha)
    • err will contain an error message, like if your salt is too small/large for the method
  • ok = crypt.check(key,hash)
    • Check if a key encodes to a given hash

Example:

local crypt = require'crypt'
local password = 'password'

print(crypt.encrypt('sha512',password,'aaaaaaaa'))
-- prints $6$aaaaaaaa$8rNtDLZ8RXl80fZr/95gEzOX1gZZSL2k8PeA8QihUS8vNBqdQSuQhNemROpSh/izYGOrflqsXDYtPr5f.f21I.

LICENSE

MIT - see file LICENSE

Some encryption functions are from the musl C library (also MIT-licensed), see: https://git.musl-libc.org/cgit/musl/tree/src/crypt

From musl:

  • src/crypt_md5.c
  • src/crypt_sha256.c
  • src/crypt_sha512.c

The base64 functions are from https://github.com/joedf/base64.c (also MIT-licensed).

From https://github.com/joedf/base64.c:

  • src/base64.c
  • src/base64.h

The sha1 functions (sha1.c, sha1.h) are from https://tools.ietf.org/html/rfc3174

lua-crypt's People

Contributors

jprjr avatar

Watchers

James Cloos avatar wfhao 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.