From 1429bcc7fed522b2eac523118ffca0b2486578e1 Mon Sep 17 00:00:00 2001 From: Michael Zabka Date: Mon, 23 Mar 2015 19:20:49 +0100 Subject: [PATCH] Add library crypto-js --- crypto-js/crypto-js-tests.ts | 23 +++++++++++++ crypto-js/crypto-js.d.ts | 67 ++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 crypto-js/crypto-js-tests.ts create mode 100644 crypto-js/crypto-js.d.ts diff --git a/crypto-js/crypto-js-tests.ts b/crypto-js/crypto-js-tests.ts new file mode 100644 index 0000000000..199c32ef2f --- /dev/null +++ b/crypto-js/crypto-js-tests.ts @@ -0,0 +1,23 @@ +/// + +import CryptoJS = require('crypto-js'); + +var str: string; + +str = CryptoJS.MD5('some message'); +str = CryptoJS.MD5('some message', 'some key'); + +str = CryptoJS.SHA1('some message'); +str = CryptoJS.SHA1('some message', 'some key', { any: true }); + +str = CryptoJS.format.OpenSSL('some message'); +str = CryptoJS.format.OpenSSL('some message', 'some key'); + +str = CryptoJS.enc.Utf8('some message'); +str = CryptoJS.enc.Utf8('some message', 'some key'); + +str = CryptoJS.mode.OFB('some message'); +str = CryptoJS.mode.OFB('some message', 'some key'); + +str = CryptoJS.pad.Ansix923('some message'); +str = CryptoJS.pad.Ansix923('some message', 'some key'); diff --git a/crypto-js/crypto-js.d.ts b/crypto-js/crypto-js.d.ts new file mode 100644 index 0000000000..0f02514027 --- /dev/null +++ b/crypto-js/crypto-js.d.ts @@ -0,0 +1,67 @@ +// Type definitions for crypto-js v3.1.3 +// Project: https://github.com/evanvosberg/crypto-js +// Definitions by: Michael Zabka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module CryptoJS { + type Hash = (message: string, key?: string, ...options: any[]) => string; + + export interface Hashes { + MD5: Hash; + SHA1: Hash; + SHA256: Hash; + SHA224: Hash; + SHA512: Hash; + SHA384: Hash; + SHA3: Hash; + RIPEMD160: Hash; + HmacMD5: Hash; + HmacSHA1: Hash; + HmacSHA256: Hash; + HmacSHA224: Hash; + HmacSHA512: Hash; + HmacSHA384: Hash; + HmacSHA3: Hash; + HmacRIPEMD160: Hash; + PBKDF2: Hash; + AES: Hash; + TripleDES: Hash; + RC4: Hash; + Rabbit: Hash; + RabbitLegacy: Hash; + EvpKDF: Hash; + format: { + OpenSSL: Hash; + Hex: Hash; + }; + enc: { + Latin1: Hash; + Utf8: Hash; + Hex: Hash; + Utf16: Hash; + Base64: Hash; + }; + mode: { + CFB: Hash; + CTR: Hash; + CTRGladman: Hash; + OFB: Hash; + ECB: Hash; + }; + pad: { + Pkcs7: Hash; + Ansix923: Hash; + Iso10126: Hash; + Iso97971: Hash; + ZeroPadding: Hash; + NoPadding: Hash; + }; + } + + export var hashes: Hashes; +} + +declare module 'crypto-js' { + import hashes = CryptoJS.hashes; + export = hashes; +}