@liuit/core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/dist/aop/AopUtil.d.ts +26 -0
- package/dist/aop/ClassUtil.d.ts +39 -0
- package/dist/aop/MethodHandler.d.ts +33 -0
- package/dist/aop/TestAopUtil.d.ts +5 -0
- package/dist/common/Constant.d.ts +8 -0
- package/dist/common/adapter/StorageApi.d.ts +48 -0
- package/dist/common/auto/AutoSize.d.ts +56 -0
- package/dist/common/enums/index.d.ts +25 -0
- package/dist/common/index.d.ts +20 -0
- package/dist/common/utils/AssertUtil.d.ts +17 -0
- package/dist/common/utils/BrowserUtil.d.ts +11 -0
- package/dist/common/utils/CommonTreeUtil.d.ts +20 -0
- package/dist/common/utils/CommonUtil.d.ts +200 -0
- package/dist/common/utils/ConfigUtil.d.ts +13 -0
- package/dist/common/utils/CookieUtil.d.ts +50 -0
- package/dist/common/utils/DateUtil.d.ts +50 -0
- package/dist/common/utils/EnumUtil.d.ts +101 -0
- package/dist/common/utils/EventBus.d.ts +22 -0
- package/dist/common/utils/FileUtil.d.ts +64 -0
- package/dist/common/utils/OssUtil.d.ts +29 -0
- package/dist/common/utils/ProxyUtil.d.ts +27 -0
- package/dist/common/utils/RegexUtil.d.ts +67 -0
- package/dist/common/utils/StorageUtil.d.ts +46 -0
- package/dist/common/utils/UrlUtil.d.ts +53 -0
- package/dist/common/utils/ZeroUtil.d.ts +68 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.umd.js +1 -0
- package/dist/ioc/common/Container.d.ts +100 -0
- package/dist/ioc/common/IocContext.d.ts +61 -0
- package/dist/ioc/decorators/index.d.ts +19 -0
- package/dist/ioc/index.d.ts +11 -0
- package/dist/ioc/model/Meta.d.ts +51 -0
- package/dist/ioc/util/IocDecoratorUtil.d.ts +23 -0
- package/dist/ioc/util/IocUtil.d.ts +30 -0
- package/dist/logger/index.d.ts +117 -0
- package/dist/model/CommonMenuTree.d.ts +28 -0
- package/dist/model/CommonTree.d.ts +21 -0
- package/dist/model/DictDto.d.ts +41 -0
- package/dist/security/encrypt/AesUtil.d.ts +36 -0
- package/dist/security/encrypt/DesUtil.d.ts +38 -0
- package/dist/security/encrypt/Rc4Util.d.ts +24 -0
- package/dist/security/encrypt/RsaUtil.d.ts +94 -0
- package/dist/security/encrypt/RsaUtilPlus.d.ts +75 -0
- package/dist/security/encrypt/Sm2Util.d.ts +81 -0
- package/dist/security/encrypt/Sm4Util.d.ts +30 -0
- package/dist/security/hash/HashUtil.d.ts +23 -0
- package/dist/security/index.d.ts +18 -0
- package/dist/security/model/index.d.ts +31 -0
- package/dist/security/test/TestRsaUtil.d.ts +8 -0
- package/dist/security/test/TestRsaUtilPlus.d.ts +8 -0
- package/dist/security/test/TestSm2Enc.d.ts +1 -0
- package/dist/security/test/TestSm2Encrypt.d.ts +6 -0
- package/dist/security/test/TestSm2Util.d.ts +8 -0
- package/dist/security/test/TestSm4Util.d.ts +8 -0
- package/dist/security/test/TestSmExchange.d.ts +8 -0
- package/dist/utils/CryptoWebUtil.d.ts +21 -0
- package/dist/utils/TestPwd.d.ts +3 -0
- package/dist/validator/ValidatorUtil.d.ts +7 -0
- package/package.json +86 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import CryptoJS from 'crypto-js';
|
|
2
|
+
/**
|
|
3
|
+
* 【弃用】--安全系数低
|
|
4
|
+
* @deprecated 安全系数低
|
|
5
|
+
*@desc DES基本被淘汰,安全程度入不AES
|
|
6
|
+
*@author liudejian
|
|
7
|
+
*@date 2025-09-14 17:14
|
|
8
|
+
**/
|
|
9
|
+
export declare class DesUtil {
|
|
10
|
+
/**
|
|
11
|
+
* AES-128:128位(16字节)
|
|
12
|
+
* AES-192:192位(24字节)
|
|
13
|
+
* AES-256:256位(32字节)
|
|
14
|
+
* 密钥长度越长,破解难度越大(如AES-256的安全性高于AES-128)
|
|
15
|
+
*/
|
|
16
|
+
static readonly VITE_GLOB_DEFAULT_KEY = "13k86xyzd5r62425";
|
|
17
|
+
/**
|
|
18
|
+
* IV(初始化向量):增强加密随机性的关键参数,与KEY不同,IV不需要保密,但必须唯一
|
|
19
|
+
* IV的长度必须与AES的 块大小一致(128位/16字节)。这是因为AES是分组加密算法,每次处理16字节的数据块,IV需匹配块大小才能正确发挥作用
|
|
20
|
+
*/
|
|
21
|
+
static readonly VITE_GLOB_DEFAULT_IV = "9zo45lq09q1p8865";
|
|
22
|
+
static readonly DEFAULT_KEY: CryptoJS.lib.WordArray;
|
|
23
|
+
static readonly DEFAULT_IV: CryptoJS.lib.WordArray;
|
|
24
|
+
/**
|
|
25
|
+
* 加密数据
|
|
26
|
+
* @param data 待加密数据
|
|
27
|
+
* @param secretKey 加密KEY
|
|
28
|
+
* @param iv 初始化向量
|
|
29
|
+
*/
|
|
30
|
+
static encrypt(data: string, secretKey?: string, iv?: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* 解密数据
|
|
33
|
+
* @param encDta 待解密数据
|
|
34
|
+
* @param secretKey 解密kEY
|
|
35
|
+
* @param iv 初始化向量
|
|
36
|
+
*/
|
|
37
|
+
static decrypt(encDta: string, secretKey?: string, iv?: string): string;
|
|
38
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 【弃用】--安全系数低
|
|
3
|
+
* @deprecated 安全系数低
|
|
4
|
+
* RC4因高效、轻量,适合资源受限且对安全性要求较低的场景:
|
|
5
|
+
* RC4已被国际密码学界【弃用】:2015年RFC 7465明确禁止在TLS中使用RC4;2020年NIST建议停止使用RC4,因其漏洞易被利用(如捕获少量密文即可恢复密钥)
|
|
6
|
+
*@desc
|
|
7
|
+
*@author liudejian
|
|
8
|
+
*@date 2025-09-14 17:44
|
|
9
|
+
**/
|
|
10
|
+
export declare class Rc4Util {
|
|
11
|
+
static readonly DEFAULT_KEY = "b66a46f80fb114aef5240eec328bfe3c";
|
|
12
|
+
/**
|
|
13
|
+
* 加密数据
|
|
14
|
+
* @param data
|
|
15
|
+
* @param secretKey
|
|
16
|
+
*/
|
|
17
|
+
static encrypt(data: string, secretKey?: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* 解密数据
|
|
20
|
+
* @param encData
|
|
21
|
+
* @param secretKey
|
|
22
|
+
*/
|
|
23
|
+
static decrypt(encData: string, secretKey?: string): string;
|
|
24
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { RsaKey } from "../model";
|
|
2
|
+
export type Curve = "secp256r1" | "secp256k1" | "secp384r1";
|
|
3
|
+
export type RSAHashAlg = "sha1" | "sha256" | "sha512" | "md5" | "ripemd-160" | "sha1withrsa" | "sha256withrsa" | "sha512withrsa";
|
|
4
|
+
/**
|
|
5
|
+
* 来源:cryptojs/jsrsa
|
|
6
|
+
*/
|
|
7
|
+
export type CryptoHashAlg = "MD5withRSA" | "SHA1withRSA" | "SHA224withRSA" | "SHA256withRSA" | "SHA384withRSA" | "SHA512withRSA" | "RIPEMD160withRSA" | "MD5withECDSA" | "SHA1withECDSA" | "SHA224withECDSA" | "SHA256withECDSA" | "SHA384withECDSA" | "SHA512withECDSA" | "RIPEMD160withECDSA" | "MD5withRSAandMGF1" | "SHAwithRSAandMGF1" | "SHA1withRSAandMGF1" | "SHA224withRSAandMGF1" | "SHA256withRSAandMGF1" | "SHA384withRSAandMGF1" | "SHA512withRSAandMGF1" | "RIPEMD160withRSAandMGF1" | "SHA1withDSA" | "SHA224withDSA" | "SHA256withDSA";
|
|
8
|
+
/**
|
|
9
|
+
* 使用说明:
|
|
10
|
+
* 1. ECDSA的核心是数字签名:ECDSA用于验证消息的完整性和发送方身份,而非加密大量数据。若需加密数据,
|
|
11
|
+
* 应使用对称加密(如AES)+ 非对称加密(如RSA)的组合(如RSA-OAEP用于加密AES密钥,AES用于加密数据)。
|
|
12
|
+
* 2. 密钥管理:私钥必须严格保密,公钥可公开分发。私钥泄露会导致签名伪造风险。
|
|
13
|
+
* 3. 曲线选择:ECDSA的曲线类型(如secp256r1、secp384r1)影响安全性与性能,secp256r1是目前最常用的平衡选择。
|
|
14
|
+
*
|
|
15
|
+
*@desc RSA工具【目前@types/jsrsasign=10.5.15 与 jsrsasign=11.1.0 版本 不完全适配,
|
|
16
|
+
* 例如:encrypt 与 decrypt 不兼容,加密与解密使用jsencrypt替代】
|
|
17
|
+
*@author liudejian
|
|
18
|
+
*@date 2020-06-26 20:56
|
|
19
|
+
**/
|
|
20
|
+
export declare class RsaUtil {
|
|
21
|
+
private static RSA_PRIVATE_KEY;
|
|
22
|
+
private static RSA_PUBLIC_KEY;
|
|
23
|
+
private static readonly DEFAULT_KEY_SIZE;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* RSA 密钥对
|
|
27
|
+
* @param keySize 512/1024/2048/4096
|
|
28
|
+
*/
|
|
29
|
+
static genRSAKey(keySize: number): RsaKey;
|
|
30
|
+
/**
|
|
31
|
+
* 源自 椭圆曲线密码学(ECC),它依赖于 椭圆曲线离散对数问题(ECDLP)——在椭圆曲线上找到一个随机点的离散对数在计算上是不可行的。这使得 ECDSA 在相同安全级别下比 RSA 更高效。
|
|
32
|
+
* EC 密钥对 ECDSA
|
|
33
|
+
* @param curve "secp256r1" | "secp256k1" | "secp384r1" 目前:secp256r1性能较高
|
|
34
|
+
*/
|
|
35
|
+
static genECKey(curveStr: Curve): RsaKey;
|
|
36
|
+
/**
|
|
37
|
+
* 【公钥签名,私钥验证 | 私钥签名,公钥验证】
|
|
38
|
+
* @see https://github.com/kjur/jsrsasign/tree/master/sample
|
|
39
|
+
* @param data 待签名数据
|
|
40
|
+
* @param rsaKey rsa的公钥或者私钥
|
|
41
|
+
* @param hashAlg hash算法
|
|
42
|
+
*/
|
|
43
|
+
static signRyRsa(data: string, rsaKey: string, hashAlg: RSAHashAlg): string;
|
|
44
|
+
/**
|
|
45
|
+
* 验证签名【公钥签名,私钥验证 | 私钥签名,公钥验证】
|
|
46
|
+
* @param signStr 签名值
|
|
47
|
+
* @param data 原始数据
|
|
48
|
+
* @param rsaKey rsa的公钥或者私钥
|
|
49
|
+
* @param hashAlg 签名算法
|
|
50
|
+
*/
|
|
51
|
+
static verifByRsa(data: string, signStr: string, rsaKey: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* EC签名
|
|
54
|
+
* @param data 待签名数据
|
|
55
|
+
* @param ecKey 【公钥|私钥】
|
|
56
|
+
* @param sigAlg 签名算法
|
|
57
|
+
* @param privPass 私钥密码【选填】
|
|
58
|
+
* @return 返回16进制签名值
|
|
59
|
+
*/
|
|
60
|
+
static signRyEc(data: string, ecKey: string, sigAlg: CryptoHashAlg, privPass?: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* 验证签名
|
|
63
|
+
* @param data 待验证数据
|
|
64
|
+
* @param signStr 签名值
|
|
65
|
+
* @param rsaKey 【公钥|私钥】
|
|
66
|
+
* @param sigAlg 签名算法
|
|
67
|
+
* @param privPass 私钥密码【选填】
|
|
68
|
+
*/
|
|
69
|
+
static verifByEc(data: string, signStr: string, ecKey: string, sigAlg: CryptoHashAlg, privPass?: string): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* 公钥加密
|
|
72
|
+
* @param plaintext 待加密内容
|
|
73
|
+
* @param publicKey 公钥字符串
|
|
74
|
+
*/
|
|
75
|
+
static publicEncrypt(plaintext: string, publicKey?: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* 公钥解密
|
|
78
|
+
* @param plaintext 密文
|
|
79
|
+
* @param publicKey 公钥
|
|
80
|
+
*/
|
|
81
|
+
static publicDecrypt(ciphertext: string, publicKey?: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* 私钥加密
|
|
84
|
+
* @param plaintext 明文
|
|
85
|
+
* @param privateKey 私钥
|
|
86
|
+
*/
|
|
87
|
+
static privateEncrypt(plaintext: string, privateKey?: string): string;
|
|
88
|
+
/**
|
|
89
|
+
* 私钥解密
|
|
90
|
+
* @param ciphertext 密文
|
|
91
|
+
* @param privateKey 私钥
|
|
92
|
+
*/
|
|
93
|
+
static privateDecrypt(ciphertext: string, privateKey?: string): string;
|
|
94
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import JSEncrypt from 'jsencrypt';
|
|
2
|
+
import { RsaKey } from "../model";
|
|
3
|
+
export interface JSEncryptOptions {
|
|
4
|
+
key?: any;
|
|
5
|
+
default_key_size?: string;
|
|
6
|
+
default_public_exponent?: string;
|
|
7
|
+
log?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type DigestName = "SHA256" | "SHA1" | "MD5" | "SHA512";
|
|
10
|
+
/**
|
|
11
|
+
*@desc 【该类目前就jsencrypt-3.4.0 版本可用】
|
|
12
|
+
*@author liudejian
|
|
13
|
+
*@date 2020-06-26 20:56
|
|
14
|
+
**/
|
|
15
|
+
export declare class RsaUtilPlus {
|
|
16
|
+
private static RSA_PRIVATE_KEY;
|
|
17
|
+
private static RSA_PUBLIC_KEY;
|
|
18
|
+
private static readonly DEFAULT_KEY_SIZE;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param options
|
|
22
|
+
* options.default_key_size ( 512, 1024, 2048, 4096)
|
|
23
|
+
*/
|
|
24
|
+
static getJsEncrypt(options: JSEncryptOptions): JSEncrypt;
|
|
25
|
+
/**
|
|
26
|
+
* 获取默认JSEncrypt
|
|
27
|
+
*/
|
|
28
|
+
static getDefaultJsEncrypt(): JSEncrypt;
|
|
29
|
+
/**
|
|
30
|
+
* 生成 公钥与私钥
|
|
31
|
+
* @param keySize (512, 1024, 2048, 4096)
|
|
32
|
+
* @return ary[0]=公钥 ary[1]=私钥
|
|
33
|
+
*/
|
|
34
|
+
static genRSAKey(keySize: number): RsaKey;
|
|
35
|
+
/**
|
|
36
|
+
* 公钥加密
|
|
37
|
+
* @param plaintext 待加密内容
|
|
38
|
+
* @param publicKey 公钥字符串
|
|
39
|
+
* @param isOaep 是否使用oaep加密
|
|
40
|
+
*/
|
|
41
|
+
static publicEncrypt(plaintext: string, publicKey?: string, isOaep?: boolean): string;
|
|
42
|
+
/**
|
|
43
|
+
* 生产环境强烈建议使用标准流程(公钥加密+私钥解密)。
|
|
44
|
+
* 公钥解密【暂时不支持】
|
|
45
|
+
* @param plaintext 密文
|
|
46
|
+
* @param publicKey 公钥
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* 生产环境强烈建议使用标准流程(公钥加密+私钥解密)。
|
|
50
|
+
* 私钥加密 【暂时不支持】
|
|
51
|
+
* @param plaintext 明文
|
|
52
|
+
* @param privateKey 私钥
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* 私钥解密
|
|
56
|
+
* @param ciphertext 密文
|
|
57
|
+
* @param privateKey 私钥
|
|
58
|
+
*/
|
|
59
|
+
static privateDecrypt(ciphertext: string, privateKey?: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* 私钥 签名
|
|
62
|
+
* @param data 待签名数据
|
|
63
|
+
* @param privateKey 私钥
|
|
64
|
+
* @param digestName 签名算法
|
|
65
|
+
* @return false表示失败。 成功返回签名值
|
|
66
|
+
*/
|
|
67
|
+
static sign(data: string, privateKey: string, digestName: DigestName): string;
|
|
68
|
+
/**
|
|
69
|
+
* 验证签名值
|
|
70
|
+
* @param data 原始数据
|
|
71
|
+
* @param signText 签名值
|
|
72
|
+
* @param publicKey 公钥
|
|
73
|
+
*/
|
|
74
|
+
static verify(data: string, signText: string, publicKey: string, digestName: DigestName): boolean;
|
|
75
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { RsaKey, Sm2Option } from "../model";
|
|
2
|
+
export declare class Sm2Util {
|
|
3
|
+
static genKeyPair(): RsaKey;
|
|
4
|
+
/**
|
|
5
|
+
* 加密数据
|
|
6
|
+
* @param data 待加密数据
|
|
7
|
+
* @param key 加密KEY(公钥|私钥)
|
|
8
|
+
* @param cipherMode // 1 - C1C3C2| 0 - C1C2C3,默认为1
|
|
9
|
+
* @param asn1 支持使用 asn1 对加密结果进行编码,在 options 参数中传入 { asn1: true } 即可,默认不开启
|
|
10
|
+
*/
|
|
11
|
+
static encrypt(data: string, pubKey: string, cipherMode?: number, asn1?: boolean): string;
|
|
12
|
+
/**
|
|
13
|
+
* 私钥解密
|
|
14
|
+
* @param encData 待解密数据
|
|
15
|
+
* @param privKey 私钥
|
|
16
|
+
* @param cipherMode // 1 - C1C3C2,0 - C1C2C3,默认为1
|
|
17
|
+
* @param asn1 支持使用 asn1 对加密结果进行编码,在 options 参数中传入 { asn1: true } 即可,默认不开启
|
|
18
|
+
*/
|
|
19
|
+
static decrypt(encData: string, privateKey: string, cipherMode?: number, asn1?: boolean): string;
|
|
20
|
+
/**
|
|
21
|
+
* 签名
|
|
22
|
+
* @param data 待签名数据
|
|
23
|
+
* @param privateKey 私钥
|
|
24
|
+
* @param options 配置参数【选填】
|
|
25
|
+
*/
|
|
26
|
+
static sign(data: string, privateKey: string, options?: Sm2Option): string;
|
|
27
|
+
/**
|
|
28
|
+
* 验证签名
|
|
29
|
+
* @param data 待验证数据
|
|
30
|
+
* @param signStr 签名值
|
|
31
|
+
* @param publicKey 公钥
|
|
32
|
+
* @param options 配置参数【选填】
|
|
33
|
+
*/
|
|
34
|
+
static verify(data: string, signStr: string, publicKey: string, options?: Sm2Option): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* 根据私钥获取公钥
|
|
37
|
+
* @param privateKey 私钥
|
|
38
|
+
*/
|
|
39
|
+
static getPublicKey(privateKey: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* 主要用于计算数据摘要hash
|
|
42
|
+
* 应用场景:发送方计算原始数据的SM3摘要并随数据传输,接收方收到数据后重新计算摘要,比对两者是否一致:
|
|
43
|
+
* @param data 待计算数据
|
|
44
|
+
* @param keyStr // 要求为 16 进制串或字节数组
|
|
45
|
+
* @param mode
|
|
46
|
+
*/
|
|
47
|
+
static sm3Hash(data: string, keyStr?: string, mode?: "hmac" | "mac"): string;
|
|
48
|
+
/**
|
|
49
|
+
* KDF(密钥派生函数)的核心作用是通过伪随机函数(如SM3哈希)从主密钥、密码或椭圆曲线点等输入中,派生出符合加密要求的密钥(如SM4的对称密钥),解决直接使用原始密钥可能存在的安全问题(如长度不足、随机性不够)。其应用场景主要集中在需要
|
|
50
|
+
*1.对称加密密钥生成(如SM2加密流程)
|
|
51
|
+
* 2. 密码存储与验证(如用户密码保护)
|
|
52
|
+
* 3. 数字信封密钥封装(如PKCS#7数字信封)
|
|
53
|
+
* 4. 大块数据加密(如金融、交通等领域的大数据场景)
|
|
54
|
+
* 5. 密钥交换与协商(如SM2密钥交换协议)
|
|
55
|
+
* @param data
|
|
56
|
+
* @param length
|
|
57
|
+
*/
|
|
58
|
+
static kdfHash(data: string, length: number): string;
|
|
59
|
+
/**
|
|
60
|
+
* ArrayBuffer 转 十六进制
|
|
61
|
+
* @param uint8Array
|
|
62
|
+
*/
|
|
63
|
+
static arrayToHex(uint8Array: Uint8Array<ArrayBuffer>): string;
|
|
64
|
+
/**
|
|
65
|
+
* 十六进制转 ArrayBuffer
|
|
66
|
+
* @param hexData
|
|
67
|
+
*/
|
|
68
|
+
static hexToArray(hexData: string): Uint8Array<ArrayBuffer>;
|
|
69
|
+
/**
|
|
70
|
+
* 生成共享秘钥
|
|
71
|
+
* @param keyPairA A的秘钥对
|
|
72
|
+
* @param tempKeyPairA A的临时秘钥对
|
|
73
|
+
* @param publicKeyB B的公钥
|
|
74
|
+
* @param tempPublicKeyB B的临时公钥
|
|
75
|
+
* @param sharedKeyLen 生成的共享秘钥长度
|
|
76
|
+
* @param isReceiver 是否为接收方(例如:A发送数据给B,那么A方isReceiver=false, B方isReceiver=true)
|
|
77
|
+
* @param identityA A的身份: 例如:A的邮箱或者固定KEY【选填】
|
|
78
|
+
* @param identityB B的身份: 例如:B的邮箱或者固定KEY【选填】
|
|
79
|
+
*/
|
|
80
|
+
static genSharedKey(keyPairA: RsaKey, tempKeyPairA: RsaKey, publicKeyB: string, tempPublicKeyB: string, sharedKeyLen: number, isReceiver: boolean, identityA?: string, identityB?: string): string;
|
|
81
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SM4Options } from "../model";
|
|
2
|
+
/**
|
|
3
|
+
* SM4是中国自主可控的国家密码算法:经过多年安全性评估(如国家密码管理局的密码模块检测),
|
|
4
|
+
* 广泛应用于金融、政务等敏感领域,是目前国内替代AES的推荐算法
|
|
5
|
+
* SM4因安全、合规,适合安全敏感且需要自主可控的场景:
|
|
6
|
+
*@desc 加解密
|
|
7
|
+
*@author liudejian
|
|
8
|
+
*@date 2025-09-14 19:04
|
|
9
|
+
**/
|
|
10
|
+
export declare class Sm4Util {
|
|
11
|
+
static readonly DEFAULT_KEY = "2cdeeb8324fc098e49d498fae4c8f526";
|
|
12
|
+
static readonly DEFAULT_IV = "fedcba98765432100123456789abcdef";
|
|
13
|
+
static readonly DEFAULT_PADDING = "pkcs#7";
|
|
14
|
+
static readonly DEFAULT_MODE = "cbc";
|
|
15
|
+
static getDefaultOptions(iv?: string): SM4Options;
|
|
16
|
+
/**
|
|
17
|
+
* 加密
|
|
18
|
+
* @param data 待加密数据
|
|
19
|
+
* @param secretKey 加密KEY
|
|
20
|
+
* @param options 可选配置
|
|
21
|
+
*/
|
|
22
|
+
static encrypt(data: string, secretKey?: string, options?: SM4Options): any;
|
|
23
|
+
/**
|
|
24
|
+
* 解密
|
|
25
|
+
* @param encData 待解密数据
|
|
26
|
+
* @param secretKey 解密KEY
|
|
27
|
+
* @param options 可选配置
|
|
28
|
+
*/
|
|
29
|
+
static decrypt(encData: string, secretKey?: string, options?: SM4Options): any;
|
|
30
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see jsr.KJUR.crypto.Util.DEFAULTPROVIDER
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
export type HashAlg = "hmacmd5" | "hmacripemd160" | "hmacsha1" | "hmacsha224" | "hmacsha256" | "hmacsha384" | "hmacsha512" | "md5" | "MD5withECDSA" | "MD5withRSA" | "MD5withRSAandMGF1" | "ripemd160" | "RIPEMD160withECDSA" | "RIPEMD160withRSA" | "RIPEMD160withRSAandMGF1" | "sha1" | "SHA1withDSA" | "SHA1withECDSA" | "SHA1withRSA" | "SHA1withRSAandMGF1" | "sha224" | "SHA224withDSA" | "SHA224withECDSA" | "SHA224withRSA" | "SHA224withRSAandMGF1" | "sha256" | "SHA256withDSA" | "SHA256withECDSA" | "SHA256withRSA" | "SHA256withRSAandMGF1" | "sha384" | "SHA384withECDSA" | "SHA384withRSA" | "SHA384withRSAandMGF1" | "sha512" | "SHA512withECDSA" | "SHA512withRSA" | "SHA512withRSAandMGF1";
|
|
6
|
+
/**
|
|
7
|
+
*@desc
|
|
8
|
+
*@author liudejian
|
|
9
|
+
*@date 2025-09-14 16:56
|
|
10
|
+
**/
|
|
11
|
+
export declare class HashUtil {
|
|
12
|
+
static md5(data: string): string;
|
|
13
|
+
static sha1(data: string): string;
|
|
14
|
+
static sha256(data: string): string;
|
|
15
|
+
static sha512(data: string): string;
|
|
16
|
+
static sha256Hex(data: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* 计算文本hash
|
|
19
|
+
* @param data 文本数据
|
|
20
|
+
* @param alg hash算法名称
|
|
21
|
+
*/
|
|
22
|
+
static hashHex(data: string, alg: HashAlg): string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*@desc
|
|
3
|
+
*@author liudejian
|
|
4
|
+
*@date 2025-09-12 8:55
|
|
5
|
+
**/
|
|
6
|
+
export { AesUtil } from "./encrypt/AesUtil";
|
|
7
|
+
export { DesUtil } from "./encrypt/DesUtil";
|
|
8
|
+
export { Rc4Util } from "./encrypt/Rc4Util";
|
|
9
|
+
export { RsaUtil } from "./encrypt/RsaUtil";
|
|
10
|
+
export { RsaUtilPlus } from "./encrypt/RsaUtilPlus";
|
|
11
|
+
export { Sm2Util } from "./encrypt/Sm2Util";
|
|
12
|
+
export { Sm4Util } from "./encrypt/Sm4Util";
|
|
13
|
+
export { HashUtil } from "./hash/HashUtil";
|
|
14
|
+
export { RsaKey } from "./model";
|
|
15
|
+
export type { HashAlg } from "./hash/HashUtil";
|
|
16
|
+
export type { Curve, RSAHashAlg, CryptoHashAlg } from "./encrypt/RsaUtil";
|
|
17
|
+
export type { DigestName, JSEncryptOptions } from "./encrypt/RsaUtilPlus";
|
|
18
|
+
export type { SignaturePoint, Sm2Option, SM4Options } from "./model";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*@desc
|
|
3
|
+
*@author liudejian
|
|
4
|
+
*@date 2025-09-14 21:45
|
|
5
|
+
**/
|
|
6
|
+
export declare class RsaKey {
|
|
7
|
+
privateKey: string;
|
|
8
|
+
publicKey: string;
|
|
9
|
+
compressedPublicKey?: string;
|
|
10
|
+
static of(privateKey: string, publicKey: string, compressedPublicKey?: string): RsaKey;
|
|
11
|
+
}
|
|
12
|
+
export interface SignaturePoint {
|
|
13
|
+
k: bigint;
|
|
14
|
+
x1: bigint;
|
|
15
|
+
}
|
|
16
|
+
export interface Sm2Option {
|
|
17
|
+
pointPool?: SignaturePoint[];
|
|
18
|
+
der?: boolean;
|
|
19
|
+
hash?: boolean;
|
|
20
|
+
publicKey?: string;
|
|
21
|
+
userId?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface SM4Options {
|
|
24
|
+
padding?: 'pkcs#7' | 'pkcs#5' | 'none' | null;
|
|
25
|
+
mode?: 'cbc' | 'ecb' | 'gcm';
|
|
26
|
+
iv?: Uint8Array<ArrayBufferLike> | string;
|
|
27
|
+
output?: 'string' | 'array';
|
|
28
|
+
associatedData?: Uint8Array<ArrayBufferLike> | string;
|
|
29
|
+
outputTag?: boolean;
|
|
30
|
+
tag?: Uint8Array<ArrayBufferLike> | string;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*@desc
|
|
3
|
+
*@author liudejian
|
|
4
|
+
*@date 2020-06-26 20:56
|
|
5
|
+
**/
|
|
6
|
+
export default class CryptoWebUtil {
|
|
7
|
+
private static RSA_PRIVATE_KEY;
|
|
8
|
+
private static RSA_PUBLIC_KEY;
|
|
9
|
+
/**
|
|
10
|
+
* 公钥-加密
|
|
11
|
+
* @param word
|
|
12
|
+
* @constructor
|
|
13
|
+
*/
|
|
14
|
+
static RsaPublicKeyEncrypt(word: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* 私钥-解密
|
|
17
|
+
* @param word
|
|
18
|
+
* @constructor
|
|
19
|
+
*/
|
|
20
|
+
static RsaPrivateKeyDescrypt(word: string): string;
|
|
21
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@liuit/core",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "一款基于typescript 前端控制组件,包括(IOC,AOP,Feign,Logger,Util等)",
|
|
6
|
+
"main": "dist/index.esm.js",
|
|
7
|
+
"module": "dist/index.esm.js",
|
|
8
|
+
"unpkg": "dist/index.esm.js",
|
|
9
|
+
"jsdelivr": "dist/index.esm.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"author": "ldj <zuiwoxing@qq.com>",
|
|
12
|
+
"license": "GNU AGPL v3",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"types",
|
|
17
|
+
"index.js"
|
|
18
|
+
],
|
|
19
|
+
"exports": {
|
|
20
|
+
".": [
|
|
21
|
+
{
|
|
22
|
+
"import": "./dist/index.esm.js",
|
|
23
|
+
"require": "./dist/index.esm.js",
|
|
24
|
+
"default": "./dist/index.esm.js"
|
|
25
|
+
},
|
|
26
|
+
"./dist/index.esm.js"
|
|
27
|
+
],
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"dev": "rollup --config rollup.config.dev.js",
|
|
32
|
+
"build": "rollup --config rollup.config.build.js"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"IOC",
|
|
36
|
+
"AOP",
|
|
37
|
+
"Feign",
|
|
38
|
+
"Log",
|
|
39
|
+
"Util"
|
|
40
|
+
],
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@babel/core": "^7.18.6",
|
|
43
|
+
"@babel/plugin-external-helpers": "^7.18.6",
|
|
44
|
+
"@babel/plugin-transform-runtime": "^7.18.6",
|
|
45
|
+
"@babel/preset-env": "^7.18.6",
|
|
46
|
+
"@fingerprintjs/fingerprintjs": "^4.6.2",
|
|
47
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
48
|
+
"@types/jsrsasign": "^10.5.15",
|
|
49
|
+
"bufferutil": "^4.0.7",
|
|
50
|
+
"crypto-js": "^4.2.0",
|
|
51
|
+
"esno": "^0.17.0",
|
|
52
|
+
"has-flag": "^5.0.1",
|
|
53
|
+
"js-cookie": "^3.0.1",
|
|
54
|
+
"jsencrypt": "3.4.0",
|
|
55
|
+
"jsrsasign": "^11.1.0",
|
|
56
|
+
"mitt": "^3.0.1",
|
|
57
|
+
"reflect-metadata": "^0.2.2",
|
|
58
|
+
"rollup-plugin-node-builtins": "^2.1.2",
|
|
59
|
+
"rollup-plugin-node-globals": "^1.4.0",
|
|
60
|
+
"simple-flakeid": "^0.0.5",
|
|
61
|
+
"sm-crypto-v2": "^1.14.0",
|
|
62
|
+
"sm-crypto-v3": "^1.0.0"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@rollup/plugin-commonjs": "^24.0.1",
|
|
66
|
+
"@rollup/plugin-eslint": "^9.0.3",
|
|
67
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
68
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
69
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
70
|
+
"@rollup/plugin-typescript": "^11.0.0",
|
|
71
|
+
"@types/crypto-js": "^4.2.2",
|
|
72
|
+
"@types/js-cookie": "^3.0.2",
|
|
73
|
+
"@typescript-eslint/parser": "^6.12.0",
|
|
74
|
+
"core-js": "^3.34.0",
|
|
75
|
+
"eslint": "^8.32.0",
|
|
76
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
77
|
+
"prettier": "^2.8.3",
|
|
78
|
+
"rollup": "^3.29.4",
|
|
79
|
+
"rollup-plugin-auto-external": "^2.0.0",
|
|
80
|
+
"rollup-plugin-delete": "^2.0.0",
|
|
81
|
+
"rollup-plugin-dts": "^5.3.1",
|
|
82
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
83
|
+
"tslib": "^2.6.2",
|
|
84
|
+
"typescript": "^5.3.3"
|
|
85
|
+
}
|
|
86
|
+
}
|