@toruslabs/eccrypto
Advanced tools
Comparing version 5.0.1 to 5.0.2
@@ -109,3 +109,3 @@ /******/ (() => { // webpackBootstrap | ||
return async function (iv, key, data) { | ||
if (subtle) { | ||
if (subtle && subtle[op] && subtle.importKey) { | ||
const importAlgorithm = { | ||
@@ -119,4 +119,16 @@ name: "AES-CBC" | ||
}; | ||
// encrypt and decrypt ops are not implemented in react-native-quick-crypto yet. | ||
const result = await subtle[op](encAlgorithm, cryptoKey, data); | ||
return Buffer.from(new Uint8Array(result)); | ||
} else if (op === "encrypt" && browserCrypto.createCipheriv) { | ||
// This is available if crypto is polyfilled in react native environment | ||
const cipher = browserCrypto.createCipheriv("aes-256-cbc", key, iv); | ||
const firstChunk = cipher.update(data); | ||
const secondChunk = cipher.final(); | ||
return Buffer.concat([firstChunk, secondChunk]); | ||
} else if (op === "decrypt" && browserCrypto.createDecipheriv) { | ||
const decipher = browserCrypto.createDecipheriv("aes-256-cbc", key, iv); | ||
const firstChunk = decipher.update(data); | ||
const secondChunk = decipher.final(); | ||
return Buffer.concat([firstChunk, secondChunk]); | ||
} | ||
@@ -123,0 +135,0 @@ throw new Error(`Unsupported operation: ${op}`); |
@@ -54,3 +54,3 @@ import { ec as ec$1 } from 'elliptic'; | ||
return async function (iv, key, data) { | ||
if (subtle) { | ||
if (subtle && subtle[op] && subtle.importKey) { | ||
const importAlgorithm = { | ||
@@ -64,4 +64,16 @@ name: "AES-CBC" | ||
}; | ||
// encrypt and decrypt ops are not implemented in react-native-quick-crypto yet. | ||
const result = await subtle[op](encAlgorithm, cryptoKey, data); | ||
return Buffer.from(new Uint8Array(result)); | ||
} else if (op === "encrypt" && browserCrypto.createCipheriv) { | ||
// This is available if crypto is polyfilled in react native environment | ||
const cipher = browserCrypto.createCipheriv("aes-256-cbc", key, iv); | ||
const firstChunk = cipher.update(data); | ||
const secondChunk = cipher.final(); | ||
return Buffer.concat([firstChunk, secondChunk]); | ||
} else if (op === "decrypt" && browserCrypto.createDecipheriv) { | ||
const decipher = browserCrypto.createDecipheriv("aes-256-cbc", key, iv); | ||
const firstChunk = decipher.update(data); | ||
const secondChunk = decipher.final(); | ||
return Buffer.concat([firstChunk, secondChunk]); | ||
} | ||
@@ -68,0 +80,0 @@ throw new Error(`Unsupported operation: ${op}`); |
@@ -56,3 +56,3 @@ 'use strict'; | ||
return async function (iv, key, data) { | ||
if (subtle) { | ||
if (subtle && subtle[op] && subtle.importKey) { | ||
const importAlgorithm = { | ||
@@ -66,4 +66,16 @@ name: "AES-CBC" | ||
}; | ||
// encrypt and decrypt ops are not implemented in react-native-quick-crypto yet. | ||
const result = await subtle[op](encAlgorithm, cryptoKey, data); | ||
return Buffer.from(new Uint8Array(result)); | ||
} else if (op === "encrypt" && browserCrypto.createCipheriv) { | ||
// This is available if crypto is polyfilled in react native environment | ||
const cipher = browserCrypto.createCipheriv("aes-256-cbc", key, iv); | ||
const firstChunk = cipher.update(data); | ||
const secondChunk = cipher.final(); | ||
return Buffer.concat([firstChunk, secondChunk]); | ||
} else if (op === "decrypt" && browserCrypto.createDecipheriv) { | ||
const decipher = browserCrypto.createDecipheriv("aes-256-cbc", key, iv); | ||
const firstChunk = decipher.update(data); | ||
const secondChunk = decipher.final(); | ||
return Buffer.concat([firstChunk, secondChunk]); | ||
} | ||
@@ -70,0 +82,0 @@ throw new Error(`Unsupported operation: ${op}`); |
@@ -54,3 +54,3 @@ import { ec as ec$1 } from 'elliptic'; | ||
return async function (iv, key, data) { | ||
if (subtle) { | ||
if (subtle && subtle[op] && subtle.importKey) { | ||
const importAlgorithm = { | ||
@@ -64,4 +64,16 @@ name: "AES-CBC" | ||
}; | ||
// encrypt and decrypt ops are not implemented in react-native-quick-crypto yet. | ||
const result = await subtle[op](encAlgorithm, cryptoKey, data); | ||
return Buffer.from(new Uint8Array(result)); | ||
} else if (op === "encrypt" && browserCrypto.createCipheriv) { | ||
// This is available if crypto is polyfilled in react native environment | ||
const cipher = browserCrypto.createCipheriv("aes-256-cbc", key, iv); | ||
const firstChunk = cipher.update(data); | ||
const secondChunk = cipher.final(); | ||
return Buffer.concat([firstChunk, secondChunk]); | ||
} else if (op === "decrypt" && browserCrypto.createDecipheriv) { | ||
const decipher = browserCrypto.createDecipheriv("aes-256-cbc", key, iv); | ||
const firstChunk = decipher.update(data); | ||
const secondChunk = decipher.final(); | ||
return Buffer.concat([firstChunk, secondChunk]); | ||
} | ||
@@ -68,0 +80,0 @@ throw new Error(`Unsupported operation: ${op}`); |
{ | ||
"name": "@toruslabs/eccrypto", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "JavaScript Elliptic curve cryptography library, includes fix to browser.js so that encrypt/decrypt works", | ||
@@ -5,0 +5,0 @@ "main": "./dist/lib.cjs/index.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
215053
1016