How to use the js-sha3.keccak256 function in js-sha3

To help you get started, we’ve selected a few js-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 gjeanmart / stackexchange / 48668-how-to-store-hash-of-an-excel-file-in-blockchain / index.js View on Github external
function hashFile(file) {
    var body = fs.readFileSync(file);
    console.log("##############################");
    console.log(body);
    console.log("##############################");
    console.log(body.toString('base64'));
    console.log("##############################");
    return keccak256(body.toString());
}
github uport-project / eth-typed-data / src / Type.js View on Github external
signHash() {
      return Buffer.from(keccak256(this.encode()), 'hex')
    }
github pandonetwork / pando / packages / pando.js / src / components / remote.ts View on Github external
import register from 'module-alias/register'

import Repository from '@components/repository'
import RemoteBranchFactory from '@factories/remote-branch-factory'
import CID from 'cids'
import { hash } from 'eth-ens-namehash'
import ethereumRegex from 'ethereum-regex'
import IPFS from 'ipfs-api'
import isIPFS from 'is-ipfs'
import { keccak256, sha3_256 } from 'js-sha3'
import util from 'util'
import web3Utils from 'web3-utils'

export default class Remote {
  public static APP_NAMESPACE = '0x' + keccak256('app')
  public static APP_BASE_NAMESPACE = '0x' + keccak256('base')
  public static TREE_BASE_APP_ID = hash('tree.pando.aragonpm.test')
  public static TREE_APP_ID = web3Utils.sha3(
    Remote.APP_BASE_NAMESPACE + Remote.TREE_BASE_APP_ID.substring(2),
    { encoding: 'hex' }
  )
  public static PROXY_APP_ID = web3Utils.sha3(
    Remote.APP_NAMESPACE + Remote.TREE_BASE_APP_ID.substring(2),
    { encoding: 'hex' }
  )

  public static async at(
    repository: Repository,
    kernelAddress: string
  ): Promise {
    const kernel = await repository.pando.contracts.kernel.at(kernelAddress)
github Cocos-BCX / CocosPayDesktop / src / renderer / utils / utils.js View on Github external
static publicKeyToAddress(pubKey) {
    const publicKey = (pubKey.length === 65) ? pubKey.slice(1) : pubKey
    const hash = keccak256(publicKey).toString()

    return ByteArray.fromHexString(address)
  }
github glowkeeper / Provenator / app / utils / writer / premisRightsHandler.jsx View on Github external
setId () {
    let key = ''
    if (this.checkSet()) {
      const keyString = this.rights.basis +
                        this.rights.status +
                        this.rights.countryCode +
                        this.rights.determinationDate +
                        this.rights.act + this.rights.restriction
      key = keccak256(keyString)
    }
    this.rights.id = key
  }
github ethereum / solc-js / linker.js View on Github external
function libraryHashPlaceholder (input) {
  return '$' + keccak256(input).slice(0, 34) + '$';
}
github pandonetwork / pando / packages / pando.js / lib / components / remote.js View on Github external
case 2:
                        PUSH = _b.sent();
                        return [4 /*yield*/, this.acl.grantPermission(who, this.tree.address, PUSH, {
                                from: this.repository.config.author.account
                            })];
                    case 3:
                        receipt = _b.sent();
                        return [3 /*break*/, 5];
                    case 4: throw new TypeError("'" + what + "' is not a valid role");
                    case 5: return [2 /*return*/, receipt];
                }
            });
        });
    };
    Remote.APP_NAMESPACE = '0x' + js_sha3_1.keccak256('app');
    Remote.APP_BASE_NAMESPACE = '0x' + js_sha3_1.keccak256('base');
    Remote.TREE_BASE_APP_ID = eth_ens_namehash_1.hash('tree.pando.aragonpm.test');
    Remote.TREE_APP_ID = web3_utils_1.default.sha3(Remote.APP_BASE_NAMESPACE + Remote.TREE_BASE_APP_ID.substring(2), { encoding: 'hex' });
    Remote.PROXY_APP_ID = web3_utils_1.default.sha3(Remote.APP_NAMESPACE + Remote.TREE_BASE_APP_ID.substring(2), { encoding: 'hex' });
    return Remote;
}());
exports.default = Remote;
github AdExNetwork / adex-protocol-eth / js / Commitment.js View on Github external
Commitment.prototype.hash = function() {
	const buf = keccak256(abi.rawEncode(
		['bytes32', 'bytes32', 'address', 'uint256', 'uint256', 'address', 'address', 'address[]', 'uint256[]'],
		[SCHEMA_HASH, this.bidId, this.tokenAddr, this.tokenAmount, this.validUntil, this.advertiser, this.publisher, this.validators, this.validatorRewards]
	))
	return '0x'+buf.toString(16)
}
github GridPlus / gridplus-sdk / src / ethereum.js View on Github external
function pubToAddrStr(pub) {
  return keccak256(pub).slice(-40);
}