Crypto.ts
1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// @ts-ignore
import type { ICrypto, Mode, Pad, ENC, OnErrorCallback, ICryptoSymmetric, WordArray} from '../utssdk/interface'
// import CryptoJS from 'crypto-es';
import CryptoJS from './lib';
import { RSAHandler } from './rsa';
// import { ICryptoFailImpl } from '../utssdk/unierror'
export class CryptoImpl implements ICrypto {
private rsaHandler: RSAHandler;
constructor() {
this.rsaHandler = new RSAHandler();
}
// @ts-ignore
get enc() {
return CryptoJS.enc //as ENC
}
// @ts-ignore
get mode() {
return CryptoJS.mode // as Mode
}
// @ts-ignore
get pad() {
return CryptoJS.pad // as Pad
}
// @ts-ignore
get AES() {
return CryptoJS.AES// as ICryptoAES
}
// @ts-ignore
get DES() {
return CryptoJS.DES// as ICryptoDES
}
get RSA() {
return this.rsaHandler;
}
// @ts-ignore
MD5(message : string){
return CryptoJS.MD5(message)//.toString()
}
// @ts-ignore
SHA1(message : string) {
return CryptoJS.SHA1(message)//.toString()
}
// @ts-ignore
SHA256(message : string) {
return CryptoJS.SHA256(message)//.toString()
}
// @ts-ignore
SHA512(message : string) {
return CryptoJS.SHA512(message)//.toString()
}
// @ts-ignore
HmacSHA256(message: string, secretKey: string|WordArray) {
return CryptoJS.HmacSHA256(message, secretKey)//.toString()
}
// @ts-ignore
HmacSHA1(message : string, secretKey : string|WordArray) {
return CryptoJS.HmacSHA1(message, secretKey)//.toString()
}
onError(callback: OnErrorCallback) {
// ICryptoFailImpl
}
}