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

gcm-stream

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gcm-stream - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

2

package.json
{
"name": "gcm-stream",
"version": "1.0.1",
"version": "1.1.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -32,2 +32,3 @@ # aes-gcm

| iv | 初始化向量| 否,如果不传内部会随机, 可以通过 encrypt.getIV |
| withoutIV | 是否自动将 IV 添加到密文前 | 否 |
| ivLength | 初始化向量随机的长度, 默认 12 bytes, 当不传递 iv 时用于自动生成 iv| 否|

@@ -37,3 +38,3 @@ | cipherGCMTypes | gcm 加密类型| 否,默认 aes-256-gcm|

## const encrypt = Encrypt(options)
## const decrypt = Decrypt(options)

@@ -49,5 +50,4 @@ 支持的参数

注意: 加密解密的 key 要一样, iv 长度和 mac 的长度也很重要,如果约定不是使用 iv 12bytes、macLength 16bytes 的情况下,需要主动的声明长度.
注意: 加密解密的 key 要一样, iv 长度和 mac 的长度也很重要,如果约定不是使用 iv 12bytes、macLength 16bytes 的情况下,需要主动的声明长度.
# 背景

@@ -54,0 +54,0 @@

@@ -7,2 +7,6 @@ /// <reference types="node" />

interface Options {
/**
* @description 不自动带上 IV 头
*/
withoutIV?: boolean;
macLength?: number;

@@ -27,2 +31,3 @@ /**

private ivLength;
private withoutIV;
private iv;

@@ -29,0 +34,0 @@ private key;

@@ -13,5 +13,6 @@ "use strict";

this.ivLength = 12;
this.withoutIV = false;
this.isFirst = true;
this.cipherGCMTypes = 'aes-256-gcm';
const { macLength, ivLength, cipherGCMTypes, key, iv } = options;
const { macLength, ivLength, cipherGCMTypes, key, iv, withoutIV } = options;
if (macLength) {

@@ -28,2 +29,3 @@ this.macLength = macLength;

this.iv = this.create(this.ivLength, iv);
this.withoutIV = Boolean(withoutIV);
this.cipher = (0, crypto_1.createCipheriv)(this.cipherGCMTypes, this.key, this.iv, {

@@ -35,3 +37,6 @@ authTagLength: this.macLength,

if (this.isFirst) {
this.push(this.getIV());
if (!this.withoutIV) {
// 现在允许不自动在头部带上 IV 的形式了
this.push(this.getIV());
}
this.isFirst = false;

@@ -38,0 +43,0 @@ }

Sorry, the diff of this file is not supported yet

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