How to use the sha3.SHA3 function in sha3

To help you get started, we’ve selected a few sha3 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 berty / berty / js / packages / components / chat / shared-components / Message.tsx View on Github external
(parseInt(nextMessage?.sentDate, 10) || 0) - (sentDate || 0) < 60000 // one minute
		} else {
			isFollowupMessage =
				previousMessage && !inte.isMe && inte.memberPublicKey === previousMessage.memberPublicKey
			isFollowedMessage =
				nextMessage && !inte.isMe && inte.memberPublicKey === nextMessage.memberPublicKey

			isWithinCollapseDuration =
				nextMessage &&
				inte?.memberPublicKey === nextMessage?.memberPublicKey &&
				sentDate &&
				nextMessage.sentDate &&
				(parseInt(nextMessage?.sentDate, 10) || 0) - (sentDate || 0) < 60000 // one minute

			if (!inte.isMe && inte.memberPublicKey) {
				const h = new SHA3(256).update(inte.memberPublicKey).digest()
				baseColor = '#' + pal[h[0]]
			}
			msgTextColor = inte.isMe
				? inte.acknowledged
					? color.white
					: cmd
					? color.grey
					: baseColor
				: baseColor
			msgBackgroundColor = inte.isMe
				? inte.acknowledged
					? baseColor
					: color.white
				: Color(baseColor).alpha(0.1).string()
			msgBorderColor = inte.isMe && (cmd ? border.color.grey : { borderColor: baseColor })
			msgSenderColor = inte.isMe ? 'red' : baseColor
github bandprotocol / libra-web / packages / libra-web-core / index.ts View on Github external
const senderAccountState = await this.getAccountState(senderAddress)
      sequenceNumber = senderAccountState.sequenceNumber
    }

    const rawTransaction = new RawTransaction()
    rawTransaction.setSenderAccount(senderAddress.toBytes())
    rawTransaction.setSequenceNumber(sequenceNumber.toNumber())
    rawTransaction.setProgram(transaction.program)
    rawTransaction.setMaxGasAmount(transaction.gasContraint.maxGasAmount.toNumber())
    rawTransaction.setGasUnitPrice(transaction.gasContraint.gasUnitPrice.toNumber())
    rawTransaction.setExpirationTime(transaction.expirationTime.toNumber())

    const signedTransaction = new SignedTransaction()
    signedTransaction.setSenderPublicKey(sender.keyPair.getPublicKey())

    const sha3 = new SHA3(256)
    // Magic number provided by Libra
    sha3.update('46f174df6ca8de5ad29745f91584bb913e7df8dd162e3e921a5c1d8637c88d16', 'hex')
    sha3.update(new Buffer(rawTransaction.serializeBinary()))

    signedTransaction.setSenderSignature(sender.generateSignature(sha3.digest()))
    signedTransaction.setRawTxnBytes(rawTransaction.serializeBinary())

    const request = new SubmitTransactionRequest()
    request.setSignedTxn(signedTransaction)
    return new Promise((resolve, reject) => {
      this.client.submitTransaction(request, undefined, (error: any | null, response: SubmitTransactionResponse) => {
        if (error) {
          return reject(error)
        }
        resolve(response)
      })
github bandprotocol / libra-web / packages / libra-web-account / Accounts.ts View on Github external
public getAddress(): AccountAddress {
    if (this.address !== undefined) {
      return this.address
    }

    const sha3 = new SHA3(256)
    sha3.update(Buffer.from(this.keyPair.getPublicKey()))
    this.address = new AccountAddress(new Uint8Array(sha3.digest()))
    return this.address
  }
github iotaledger / poc-ipfs / client / src / app / routes / UploadFile.tsx View on Github external
private setAlgorithm(algo: string): void {
        if (this.state.fileBuffer) {
            let finalHash;

            if (algo === "sha256") {
                const hashAlgo = crypto.createHash(algo);
                hashAlgo.update(this.state.fileBuffer);
                finalHash = hashAlgo.digest("hex");
            } else {
                const hashAlgo = new SHA3(256);
                hashAlgo.update(this.state.fileBuffer);
                finalHash = hashAlgo.digest("hex");
            }

            this.setState({
                fileAlgorithm: algo,
                fileHash: finalHash
            });
        }
    }
}
github guardicore / monkey / monkey / monkey_island / cc / ui / src / services / AuthService.js View on Github external
hashSha3(text) {
    let hash = new SHA3(512);
    hash.update(text);
    return this._toHexStr(hash.digest());
  }
github iost-official / iost.js / lib / structs.js View on Github external
_base_hash() {
        const hash = sha3.SHA3(256);
        hash.update(this._bytes(0));
        return hash.digest("binary");
    }
github kulapio / libra-core / lib / wallet / Accounts.ts View on Github external
public getAddress(): AccountAddress {
    if (this.address !== undefined) {
      return this.address;
    }

    const sha3 = new SHA3(256);
    sha3.update(Buffer.from(this.keyPair.getPublicKey()));
    this.address = new AccountAddress(new Uint8Array(sha3.digest()));
    return this.address;
  }
}
github iost-official / iost.js / lib / structs.js View on Github external
_publish_hash() {
        const hash = sha3.SHA3(256);
        hash.update(this._bytes(1));
        return hash.digest("binary");
    }
github iotaledger / poc-ipfs / api / src / routes / ipfsStore.ts View on Github external
(maxSize / 1048576).toFixed(1)} Mb.`
            );
        }

        if (buffer.length === 0) {
            throw new Error(`The file must be greater than 0 bytes in length.`);
        }

        let hex;

        if (request.algorithm === "sha256") {
            const hashAlgo = crypto.createHash(request.algorithm);
            hashAlgo.update(buffer);
            hex = hashAlgo.digest("hex");
        } else if (request.algorithm === "sha3") {
            const hashAlgo = new SHA3(256);
            hashAlgo.update(buffer);
            hex = hashAlgo.digest("hex");
        }

        if (hex !== request.hash) {
            throw new Error(
                `The hash for the file is incorrect '${request.hash}' was sent but it has been calculated as '${hex}'`);
        }

        const parts = /(https):\/\/(.*):(\d*)(.*)/.exec(config.ipfs.provider);

        const ipfsConfig = {
            protocol: parts[1],
            host: parts[2],
            port: parts[3],
            "api-path": parts[4],

sha3

The Keccak family of hashing algorithms.

MIT
Latest version published 4 years ago

Package Health Score

53 / 100
Full package analysis