Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ton-crypto

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ton-crypto - npm Package Compare versions

Comparing version 1.3.2 to 1.4.0

8

dist/primitives/getSecureRandom.js

@@ -5,2 +5,3 @@ "use strict";

const nodeCrypto = typeof window === 'undefined' ? require('crypto') : null;
const expoRandom = (typeof navigator !== 'undefined' && navigator.product == 'ReactNative') ? require('expo-random') : null;
async function getSecureRandomBytes(size) {

@@ -10,2 +11,5 @@ if (nodeCrypto) {

}
if (expoRandom) {
return Buffer.from(await expoRandom.getRandomBytesAsync(size));
}
else {

@@ -22,2 +26,6 @@ return Buffer.from(window.crypto.getRandomValues(new Uint8Array(size)));

}
else if (expoRandom) {
let buffer = Buffer.from(await expoRandom.getRandomBytesAsync(size * 2));
return new Uint16Array(buffer, 0, size * 2);
}
else {

@@ -24,0 +32,0 @@ return window.crypto.getRandomValues(new Uint16Array(size));

@@ -5,2 +5,3 @@ "use strict";

const nodeCrypto = typeof window === 'undefined' ? require('crypto') : null;
const expoCrypto = (typeof navigator !== 'undefined' && navigator.product == 'ReactNative') ? require('expo-crypto') : null;
async function sha256(source) {

@@ -10,2 +11,13 @@ if (nodeCrypto) {

}
else if (expoCrypto) {
let src;
if (typeof source === 'string') {
src = Buffer.from(source, 'utf-8').toString('base64');
}
else {
src = source.toString('base64');
}
let res = await expoCrypto.digestStringAsync(expoCrypto.CryptoDigestAlgorithm.SHA256, src, { encoding: expoCrypto.CryptoEncoding.BASE64 });
return Buffer.from(res, 'base64');
}
else {

@@ -12,0 +24,0 @@ if (typeof source === 'string') {

@@ -5,2 +5,3 @@ "use strict";

const nodeCrypto = typeof window === 'undefined' ? require('crypto') : null;
const expoCrypto = (typeof navigator !== 'undefined' && navigator.product == 'ReactNative') ? require('expo-crypto') : null;
async function sha512(source) {

@@ -10,2 +11,13 @@ if (nodeCrypto) {

}
else if (expoCrypto) {
let src;
if (typeof source === 'string') {
src = Buffer.from(source, 'utf-8').toString('base64');
}
else {
src = source.toString('base64');
}
let res = await expoCrypto.digestStringAsync(expoCrypto.CryptoDigestAlgorithm.SHA512, src, { encoding: expoCrypto.CryptoEncoding.BASE64 });
return Buffer.from(res, 'base64');
}
else {

@@ -12,0 +24,0 @@ if (typeof source === 'string') {

7

package.json
{
"name": "ton-crypto",
"version": "1.3.2",
"version": "1.4.0",
"repository": "https://github.com/ex3ndr/ton-crypto.git",

@@ -13,3 +13,4 @@ "author": "Steve Korshakov <steve@korshakov.com>",

"build": "rm -fr build && tsc --declaration",
"test": "jest && karma start --single-run"
"test": "jest && karma start --single-run",
"release": "yarn build && yarn test && yarn publish"
},

@@ -21,2 +22,4 @@ "devDependencies": {

"expect": "^27.1.0",
"expo-crypto": "^9.2.0",
"expo-random": "^11.2.0",
"jest": "^27.1.0",

@@ -23,0 +26,0 @@ "jest-mock": "^27.1.0",

@@ -27,3 +27,9 @@ # TON crypto

## Methods
## React Native
To make it work on react native some native modules are required:
`
expo install expo-crypto expo-random
`
## Hashing
All methods accept strings or Buffers as arguments.

@@ -30,0 +36,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc