How to use the @casual-simulation/crypto.getHash function in @casual-simulation/crypto

To help you get started, we’ve selected a few @casual-simulation/crypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github casual-simulation / aux / src / causal-trees / core2 / CausalRepoObject.spec.ts View on Github external
it('should support null for the previous commit', () => {
            const commit = repoCommit(
                'message',
                new Date(2019, 9, 4, 9, 0, 0),
                'hash',
                null
            );

            expect(commit.hash).toEqual(
                getHash([
                    'message',
                    new Date(2019, 9, 4, 9, 0, 0),
                    'hash',
                    null,
                ])
            );
        });
    });
github casual-simulation / aux / src / causal-trees / core2 / CausalRepoObject.ts View on Github external
export function repoCommit(
    message: string,
    time: Date,
    indexHash: string,
    previousCommit: string
): CausalRepoCommit {
    return {
        type: 'commit',
        message: message,
        time: time,
        index: indexHash,
        previousCommit: previousCommit,
        hash: getHash([message, time.toISOString(), indexHash, previousCommit]),
    };
}
github casual-simulation / aux / src / causal-trees / core2 / AtomIndex.ts View on Github external
export function hashAtoms(atoms: Atom[]): string {
    let hashes: string[] = [];
    for (let atom of atoms) {
        hashes.push(atom.hash);
    }
    hashes.sort();
    return getHash(hashes);
}
github casual-simulation / aux / src / causal-trees / core2 / Atom2.ts View on Github external
export function atomHash(
    id: AtomId,
    causeHash: string | null,
    value: T
): string {
    return getHash([
        causeHash || null,
        id.site,
        id.timestamp,
        id.priority,
        value,
    ]);
}