How to use the rusha function in rusha

To help you get started, we’ve selected a few rusha 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 dolthub / dolt / js / src / browser / sha1.js View on Github external
// @flow

// Copyright 2016 The Noms Authors. All rights reserved.
// Licensed under the Apache License, version 2.0:
// http://www.apache.org/licenses/LICENSE-2.0

// This is the browser version. The Node.js version is in ../sha1.js.

import Rusha from 'rusha';

const r = new Rusha();

export default function sha1(data: Uint8Array): Uint8Array {
  const ta = r.rawDigest(data);
  return new Uint8Array(ta.buffer, ta.byteOffset, ta.byteLength);
}
github RobinBressan / json-git / src / computeHash.js View on Github external
// @flow
/* eslint-disable no-bitwise */
import Rusha from 'rusha';

const rusha = new Rusha();

export type Hash = string;
export const EMPTY_HASH: Hash = '0000000000000000000000000000000000000000';

export default function computeHash(input: mixed): Hash {
    const hash = rusha.digest(typeof input === 'object' ? JSON.stringify(input) : input);
    return hash;
}
github zerobias / telegram-mtproto / src / bin.js View on Github external
import Rusha from 'rusha'
import * as CryptoJSlib from '@goodmind/node-cryptojs-aes'
const { CryptoJS } = CryptoJSlib
import { inflate } from 'pako/lib/inflate'

// import Timer from 'hirestime' //TODO remove in prod!

import random from './service/secure-random'


import { eGCD_, greater, divide_, str2bigInt, equalsInt,
  isZero, bigInt2str, copy_, copyInt_, rightShift_,
  leftShift_, sub_, add_, powMod, bpe, one } from './vendor/leemon'


const rushaInstance = new Rusha(1024 * 1024)

export const strDecToHex = str => toLower(
  bigInt2str(
    str2bigInt(str, 10, 0), 16
  ))

export function bytesToHex(bytes = []) {
  const arr = []
  for (let i = 0; i < bytes.length; i++) {
    arr.push((bytes[i] < 16 ? '0' : '') + (bytes[i] || 0).toString(16))
  }
  return arr.join('')
}

export function bytesFromHex(hexString) {
  const len = hexString.length
github zerobias / telegram-mtproto / packages / telegram-mtproto / src / bin.js View on Github external
import Rusha from 'rusha'
import * as CryptoJSlib from '@goodmind/node-cryptojs-aes'
const { CryptoJS } = CryptoJSlib
import { inflate } from 'pako/lib/inflate'

import random from './service/secure-random'

import type { PublicKeyExtended } from './service/main/index.h'

import { eGCD_, greater, divide_, str2bigInt, equalsInt,
  isZero, bigInt2str, copy_, copyInt_, rightShift_,
  leftShift_, sub_, add_, powMod, bpe, one } from 'leemon'


const rushaInstance = new Rusha(1024 * 1024)

export type Bytes = number[]

export function generateNonce() {
  const nonce = new Array(16)
  for (let i = 0; i < 16; i++)
    nonce[i] = nextRandomInt(0xFF)
  return nonce
}


export function bytesToString(bytes: Uint8Array) {
  const ln = bytes.length
  const temp = new Array(ln)
  for (let i = 0; i < ln; ++i)
    temp[i] = String.fromCharCode(bytes[i])
github box-community / box-javascript-sdk / src / util / generate-sha1.js View on Github external
reader.onload = (evt) => {
                if (!evt || !evt.target || !evt.target.result) {
                    reject();
                    return;
                }
                var rusha = new Rusha();
                resolve(base64ArrayBuffer(rusha.rawDigest(evt.target.result).buffer));

            };
            reader.readAsArrayBuffer(blob);
github box-community / box-javascript-sdk / src / util / generate-md5.js View on Github external
reader.onload = (evt) => {
                if (!evt || !evt.target || !evt.target.result) {
                    reject();
                    return;
                }
                var rusha = new Rusha();
                resolve((rusha.digestFromBuffer(evt.target.result)));

            };
            reader.readAsArrayBuffer(blob);

rusha

A high-performance pure-javascript SHA1 implementation suitable for large binary data.

MIT
Latest version published 4 years ago

Package Health Score

56 / 100
Full package analysis

Popular rusha functions