@dxos/crypto
Advanced tools
Comparing version 2.14.5 to 2.15.0
/** | ||
* Encrypt string plaintext to a base64-encoded string ciphertext. | ||
* @param {string} plaintext | ||
* @param {string} passphrase | ||
* @param {string} cipher see https://cryptojs.gitbook.io/docs/#ciphers | ||
* @returns {string} ciphertext | ||
* @param plaintext | ||
* @param passphrase | ||
* @param cipher see https://cryptojs.gitbook.io/docs/#ciphers | ||
* @returns ciphertext | ||
*/ | ||
@@ -11,8 +11,8 @@ export declare function encrypt(plaintext: string, passphrase: string, cipher?: string): any; | ||
* Decrypt from a base64-encoded string ciphertext to string plaintext. | ||
* @param {string} ciphertext | ||
* @param {string} passphrase | ||
* @param {string} cipher see https://cryptojs.gitbook.io/docs/#ciphers | ||
* @returns {string} plaintext | ||
* @param ciphertext | ||
* @param passphrase | ||
* @param cipher see https://cryptojs.gitbook.io/docs/#ciphers | ||
* @returns plaintext | ||
*/ | ||
export declare function decrypt(ciphertext: string, passphrase: string, cipher?: string): any; | ||
//# sourceMappingURL=encrypt.d.ts.map |
@@ -14,6 +14,6 @@ "use strict"; | ||
* Encrypt string plaintext to a base64-encoded string ciphertext. | ||
* @param {string} plaintext | ||
* @param {string} passphrase | ||
* @param {string} cipher see https://cryptojs.gitbook.io/docs/#ciphers | ||
* @returns {string} ciphertext | ||
* @param plaintext | ||
* @param passphrase | ||
* @param cipher see https://cryptojs.gitbook.io/docs/#ciphers | ||
* @returns ciphertext | ||
*/ | ||
@@ -28,6 +28,6 @@ function encrypt(plaintext, passphrase, cipher = 'AES') { | ||
* Decrypt from a base64-encoded string ciphertext to string plaintext. | ||
* @param {string} ciphertext | ||
* @param {string} passphrase | ||
* @param {string} cipher see https://cryptojs.gitbook.io/docs/#ciphers | ||
* @returns {string} plaintext | ||
* @param ciphertext | ||
* @param passphrase | ||
* @param cipher see https://cryptojs.gitbook.io/docs/#ciphers | ||
* @returns plaintext | ||
*/ | ||
@@ -34,0 +34,0 @@ function decrypt(ciphertext, passphrase, cipher = 'AES') { |
/** | ||
* Creates a SHA-1 hash of the supplied string, returned as a hexadecimal string. | ||
* @param {string} text | ||
* @returns {string} | ||
* @param text | ||
*/ | ||
export declare const sha1: (text: string) => any; | ||
export declare const sha1: (text: string) => string; | ||
/** | ||
* Creates a SHA-256 hash of the supplied string, returned as a hexadecimal string. | ||
* @param {string} text | ||
* @returns {string} | ||
* @param text | ||
*/ | ||
export declare const sha256: (text: string) => any; | ||
export declare const sha256: (text: string) => string; | ||
/** | ||
* Creates a SHA-512 hash of the supplied string, returned as a hexadecimal string. | ||
* @param {string} text | ||
* @returns {string} | ||
* @param text | ||
*/ | ||
export declare const sha512: (text: string) => any; | ||
export declare const sha512: (text: string) => string; | ||
/** | ||
* Creates a SHA-512 hash of the supplied string, returned as a hexadecimal string. | ||
* @param {string} text | ||
* @returns {string} | ||
* @param text | ||
*/ | ||
export declare const ripemd160: (text: string) => any; | ||
export declare const ripemd160: (text: string) => string; | ||
//# sourceMappingURL=hash.d.ts.map |
@@ -16,4 +16,2 @@ "use strict"; | ||
* @param plaintext | ||
* @returns {string} | ||
* @private | ||
*/ | ||
@@ -27,4 +25,3 @@ const _hash = (algorithm, plaintext) => { | ||
* Creates a SHA-1 hash of the supplied string, returned as a hexadecimal string. | ||
* @param {string} text | ||
* @returns {string} | ||
* @param text | ||
*/ | ||
@@ -35,4 +32,3 @@ const sha1 = (text) => _hash('SHA1', text); | ||
* Creates a SHA-256 hash of the supplied string, returned as a hexadecimal string. | ||
* @param {string} text | ||
* @returns {string} | ||
* @param text | ||
*/ | ||
@@ -43,4 +39,3 @@ const sha256 = (text) => _hash('SHA256', text); | ||
* Creates a SHA-512 hash of the supplied string, returned as a hexadecimal string. | ||
* @param {string} text | ||
* @returns {string} | ||
* @param text | ||
*/ | ||
@@ -51,4 +46,3 @@ const sha512 = (text) => _hash('SHA512', text); | ||
* Creates a SHA-512 hash of the supplied string, returned as a hexadecimal string. | ||
* @param {string} text | ||
* @returns {string} | ||
* @param text | ||
*/ | ||
@@ -55,0 +49,0 @@ const ripemd160 = (text) => _hash('RIPEMD160', text); |
{ | ||
"name": "@dxos/crypto", | ||
"version": "2.14.5", | ||
"version": "2.15.0", | ||
"description": "Basic crypto key utils", | ||
@@ -28,3 +28,4 @@ "license": "AGPL-3.0", | ||
"@types/jest": "^26.0.7", | ||
"@types/node": "^14.0.9" | ||
"@types/node": "^14.0.9", | ||
"@types/crypto-js": "~4.0.2" | ||
}, | ||
@@ -31,0 +32,0 @@ "publishConfig": { |
@@ -10,6 +10,6 @@ // | ||
* Encrypt string plaintext to a base64-encoded string ciphertext. | ||
* @param {string} plaintext | ||
* @param {string} passphrase | ||
* @param {string} cipher see https://cryptojs.gitbook.io/docs/#ciphers | ||
* @returns {string} ciphertext | ||
* @param plaintext | ||
* @param passphrase | ||
* @param cipher see https://cryptojs.gitbook.io/docs/#ciphers | ||
* @returns ciphertext | ||
*/ | ||
@@ -20,3 +20,3 @@ export function encrypt (plaintext: string, passphrase: string, cipher = 'AES') { | ||
return CryptoJS[cipher].encrypt(plaintext, passphrase).toString(); | ||
return (CryptoJS as any)[cipher].encrypt(plaintext, passphrase).toString(); | ||
} | ||
@@ -26,6 +26,6 @@ | ||
* Decrypt from a base64-encoded string ciphertext to string plaintext. | ||
* @param {string} ciphertext | ||
* @param {string} passphrase | ||
* @param {string} cipher see https://cryptojs.gitbook.io/docs/#ciphers | ||
* @returns {string} plaintext | ||
* @param ciphertext | ||
* @param passphrase | ||
* @param cipher see https://cryptojs.gitbook.io/docs/#ciphers | ||
* @returns plaintext | ||
*/ | ||
@@ -37,4 +37,4 @@ export function decrypt (ciphertext: string, passphrase: string, cipher = 'AES') { | ||
const bytes = CryptoJS[cipher].decrypt(ciphertext, passphrase); | ||
const bytes = (CryptoJS as any)[cipher].decrypt(ciphertext, passphrase); | ||
return bytes.toString(CryptoJS.enc.Utf8); | ||
} |
@@ -12,10 +12,8 @@ // | ||
* @param plaintext | ||
* @returns {string} | ||
* @private | ||
*/ | ||
const _hash = (algorithm: string, plaintext: string) => { | ||
const _hash = (algorithm: string, plaintext: string): string => { | ||
assert(typeof algorithm === 'string'); | ||
assert(typeof plaintext === 'string'); | ||
return CryptoJS[algorithm](plaintext).toString(); | ||
return (CryptoJS as any)[algorithm](plaintext).toString(); | ||
}; | ||
@@ -25,4 +23,3 @@ | ||
* Creates a SHA-1 hash of the supplied string, returned as a hexadecimal string. | ||
* @param {string} text | ||
* @returns {string} | ||
* @param text | ||
*/ | ||
@@ -33,4 +30,3 @@ export const sha1 = (text: string) => _hash('SHA1', text); | ||
* Creates a SHA-256 hash of the supplied string, returned as a hexadecimal string. | ||
* @param {string} text | ||
* @returns {string} | ||
* @param text | ||
*/ | ||
@@ -41,4 +37,3 @@ export const sha256 = (text: string) => _hash('SHA256', text); | ||
* Creates a SHA-512 hash of the supplied string, returned as a hexadecimal string. | ||
* @param {string} text | ||
* @returns {string} | ||
* @param text | ||
*/ | ||
@@ -49,5 +44,4 @@ export const sha512 = (text: string) => _hash('SHA512', text); | ||
* Creates a SHA-512 hash of the supplied string, returned as a hexadecimal string. | ||
* @param {string} text | ||
* @returns {string} | ||
* @param text | ||
*/ | ||
export const ripemd160 = (text: string) => _hash('RIPEMD160', text); |
@@ -7,2 +7,1 @@ // | ||
declare module 'hypercore-crypto'; | ||
declare module 'crypto-js'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86991
4
1197