feat(rijndael-js): Added type definitions for the rijndael-js package (#37691)

This commit is contained in:
Svet Nikolov
2019-08-16 17:15:20 -07:00
committed by Pranav Senthilnathan
parent 4e61a08d6b
commit 9a8eef8fec
4 changed files with 49 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
// Type definitions for rijndael-js 1.0
// Project: https://github.com/Snack-X/rijndael-js#readme
// Definitions by: Svet Nikolov <https://github.com/svetkomir>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
export = RijndaelBlock;
declare class RijndaelBlock {
constructor(key: Buffer | string, mode: string);
encrypt(_plaintext: Buffer | string, blockSize: string, _iv: Buffer | string): Buffer;
decrypt(_ciphertext: Buffer, blockSize: string, _iv: Buffer | string): Buffer;
}
+11
View File
@@ -0,0 +1,11 @@
import RijndaelBlock = require('rijndael-js');
const rijndaelBlockStringTest = new RijndaelBlock('12345678901234567890123456789012', 'cbc');
const rijndaelBlock = new RijndaelBlock(Buffer.from('12345678901234567890123456789012'), 'cbc');
let encryptedValue: Buffer = rijndaelBlock.encrypt('text to encrypt', '128', '1234567890123456');
encryptedValue = rijndaelBlock.encrypt(Buffer.from('text to encrypt'), '128', Buffer.from('1234567890123456'));
let decryptedValue: Buffer = rijndaelBlock.decrypt(encryptedValue, '128', '1234567890123456');
decryptedValue = rijndaelBlock.decrypt(encryptedValue, '128', Buffer.from('1234567890123456'));
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"rijndael-js-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }