Coder Social home page Coder Social logo

crypt's Introduction

crypt library for Erlang

Wrapper around the system crypt(3) library for Erlang.

WARNING

The algorithms supported by crypt are dependent on the system crypt(3) library. For example, Mac OS X only supports DES (booooooo!!!!).

USAGE

crypt(Key, Salt) -> binary()
crypt_to_string(Key, Salt) -> string()

    Types   Key = iodata()
            Salt = iodata()
            Crypted = binary()

    Calls the system crypt(3) function with the provided arguments.

    If crypt(3) is not supported by the OS, the crypt module will
    fail to load.

    Depending on your system crypt(3) library, errors may or may not
    be returned. Some implementations return NULL. If this occurs,
    crypt/2 will throw a bad arg exception. Other implementations
    may choose to return a fixed string (if this is a concern,
    the caller will need to test for this condition).

    The NetBSD man page for crypt(3) summarizes the situation as:

        The behavior of crypt() on errors isn't well standardized.
        Some implementations simply can't fail (unless the process
        dies, in which case they obviously can't return), others
        return NULL or a fixed string.  Most implementations
        don't set errno, but some do.  Version 2 of the Single
        UNIX Specification (``SUSv2'') specifies only returning
        NULL and setting errno as a valid behavior, and defines
        only one possible error (ENOSYS, ``The functionality is
        not supported on this implementation.'') Unfortunately,
        most existing applications aren't prepared to handle NULL
        returns from crypt().  The description below corresponds
        to this implementation of crypt() only.  The behavior may
        change to match standards, other implementations or existing
        applications.

        crypt() may only fail (and return) when passed an invalid
        or unsupported setting, in which case it returns a pointer
        to a magic string that is shorter than 13 characters and is
        guaranteed to differ from setting.  This behavior is safe
        for older applications which assume that crypt() can't fail,
        when both setting new passwords and authenticating against
        existing password hashes.

EXAMPLES

1> crypt:crypt("test","aa").
<<"aaqPiZY5xR5l.">>
2> crypt:crypt("test","$1$aaaaaaaa").
<<"$1$aaaaaaaa$lWxWtPmiNjS/cwJnGm6fe0">>
3> crypt:crypt("test","$6$aaaaaaaa").
<<"$6$aaaaaaaa$HREHv6TuSmUS/7spCDO5Js3ssSZ6.iwVkUoVtatJUhJDKVmERrRKBTolrPMub2s5dX6IEjZg6d6wZzFRlidV41">>
4> crypt:crypt_to_string(<<"test">>,"aa").
"aaqPiZY5xR5l."

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.