Skip to content

Commit

Permalink
Merge branch 'release/v0.17.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
holtwick committed Feb 20, 2024
2 parents 981c622 + d4a2e30 commit ee484c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zeed",
"type": "module",
"version": "0.16.11",
"version": "0.17.0",
"description": "🌱 Simple foundation library",
"author": {
"name": "Dirk Holtwick",
Expand Down
7 changes: 4 additions & 3 deletions src/common/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const CRYPTO_DEFAULT_HASH_ALG = 'SHA-256'
export const CRYPTO_DEFAULT_ALG = 'AES-GCM'
export const CRYPTO_DEFAULT_DERIVE_ALG = 'PBKDF2'
export const CRYPTO_DEFAULT_DERIVE_ITERATIONS = 100000
export const CRYPTO_DEFAULT_IV_LENGTH = 12

export async function digest(
message: BinInput,
Expand Down Expand Up @@ -74,7 +75,7 @@ export async function encrypt(
key: CryptoKey,
): Promise<Uint8Array> {
const MAGIC_ID = getMagicId()
const iv = randomUint8Array(12)
const iv = randomUint8Array(CRYPTO_DEFAULT_IV_LENGTH)
const cipher = await crypto.subtle.encrypt(
{ name: CRYPTO_DEFAULT_ALG, iv },
key,
Expand All @@ -100,8 +101,8 @@ export async function decrypt(
if (!equalBinary(magic, getMagicId()))
return Promise.reject(new Error(`Unknown magic ${magic}`))

const iv = data.subarray(2, 2 + 12)
const cipher = data.subarray(2 + 12, data.length)
const iv = data.subarray(2, 2 + CRYPTO_DEFAULT_IV_LENGTH)
const cipher = data.subarray(2 + CRYPTO_DEFAULT_IV_LENGTH, data.length)
const plain = await crypto.subtle.decrypt(
{ name: CRYPTO_DEFAULT_ALG, iv },
key,
Expand Down

0 comments on commit ee484c6

Please sign in to comment.