class EE::System::SHA1

Overview

SHA-1 (FIPS 180-4) message digest. More…

#include <sha1.hpp>

class SHA1 {
public:
    // typedefs

    typedef std::array<Uint8, 20> Digest;

    // structs

    struct Context;
    struct Result;

    // methods

    static Result fromStream(IOStream& stream);
    static Result fromFile(std::string path);
    static Result fromMemory(const Uint8* data, Uint64 size);
    static Result fromString(const std::string& str);
    static Result fromString(const String& str);
    static void init(Context& ctx);
    static void update(Context& ctx, const void* data, unsigned long size);
    static void final(Digest& result, Context& ctx);
    static Result result(Context& ctx);
    static std::string hexDigest(const Digest& digest);
};

Detailed Documentation

SHA-1 (FIPS 180-4) message digest.

SHA-1 is not collision resistant: use it for identifiers and interoperability (for example OpenSSH’s C token or hashed known_hosts names), never for new security-sensitive designs.

Methods

static Result fromStream(IOStream& stream)

Returns:

Calculates the sha1 hash from a stream

static Result fromFile(std::string path)

Calculates the sha1 hash from a file

static Result fromMemory(const Uint8* data, Uint64 size)

Calculates the sha1 hash from memory

static Result fromString(const std::string& str)

Calculates the sha1 hash from a string

static Result fromString(const String& str)

Calculates the sha1 hash from a string