-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export declare function cipherMode(key: Uint8Array): string; | ||
//# sourceMappingURL=cipher-mode.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'node-forge/lib/aes.js'; | ||
export interface Cipher { | ||
update(data: Uint8Array): Uint8Array; | ||
} | ||
export declare function createCipheriv(mode: any, key: Uint8Array, iv: Uint8Array): Cipher; | ||
export declare function createDecipheriv(mode: any, key: Uint8Array, iv: Uint8Array): Cipher; | ||
//# sourceMappingURL=ciphers-browser.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference types="node" /> | ||
import crypto from 'crypto'; | ||
export declare const createCipheriv: typeof crypto.createCipheriv; | ||
export declare const createDecipheriv: typeof crypto.createDecipheriv; | ||
//# sourceMappingURL=ciphers.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* @packageDocumentation | ||
* | ||
* Exposes an interface to AES encryption (formerly Rijndael), as defined in U.S. Federal Information Processing Standards Publication 197. | ||
* | ||
* This uses `CTR` mode. | ||
* | ||
* /** | ||
* @example | ||
* | ||
* ```js | ||
* import { create } from '@libp2p/crypto/aes' | ||
* | ||
* // Setting up Key and IV | ||
* | ||
* // A 16 bytes array, 128 Bits, AES-128 is chosen | ||
* const key128 = Uint8Array.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) | ||
* | ||
* // A 16 bytes array, 128 Bits, | ||
* const IV = Uint8Array.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) | ||
* | ||
* const decryptedMessage = 'Hello, world!' | ||
* | ||
* // Encrypting | ||
* const cipher = await crypto.aes.create(key128, IV) | ||
* const encryptedBuffer = await encrypt(Uint8Array.from(decryptedMessage)) | ||
* console.log(encryptedBuffer) | ||
* // prints: <Uint8Array 42 f1 67 d9 2e 42 d0 32 9e b1 f8 3c> | ||
* | ||
* // Decrypting | ||
* const decipher = await crypto.aes.create(key128, IV) | ||
* const decryptedBuffer = await decrypt(encryptedBuffer) | ||
* | ||
* console.log(decryptedBuffer) | ||
* // prints: <Uint8Array 42 f1 67 d9 2e 42 d0 32 9e b1 f8 3c> | ||
* | ||
* console.log(decryptedBuffer.toString('utf-8')) | ||
* // prints: Hello, world! | ||
* ``` | ||
*/ | ||
export interface AESCipher { | ||
encrypt(data: Uint8Array): Promise<Uint8Array>; | ||
decrypt(data: Uint8Array): Promise<Uint8Array>; | ||
} | ||
/** | ||
* @param key - The key, if length `16` then `AES 128` is used. For length `32`, `AES 256` is used | ||
* @param iv - Must have length `16` | ||
*/ | ||
export declare function create(key: Uint8Array, iv: Uint8Array): Promise<AESCipher>; | ||
//# sourceMappingURL=index.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { CreateOptions, AESCipher } from './interface.js'; | ||
export declare const derivedEmptyPasswordKey: { | ||
alg: string; | ||
ext: boolean; | ||
k: string; | ||
key_ops: string[]; | ||
kty: string; | ||
}; | ||
export declare function create(opts?: CreateOptions): AESCipher; | ||
//# sourceMappingURL=aes-gcm.browser.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.