|
@@ -2,6 +2,8 @@ import Base64 from 'crypto-js/enc-base64';
|
|
import Utf8 from 'crypto-js/enc-utf8';
|
|
import Utf8 from 'crypto-js/enc-utf8';
|
|
import AES from 'crypto-js/aes';
|
|
import AES from 'crypto-js/aes';
|
|
import SHA1 from 'crypto-js/sha1';
|
|
import SHA1 from 'crypto-js/sha1';
|
|
|
|
+import ECB from 'crypto-js/mode-ecb';
|
|
|
|
+import Pkcs7 from 'crypto-js/pad-pkcs7';
|
|
|
|
|
|
export const getBase64 = (content: string): string => {
|
|
export const getBase64 = (content: string): string => {
|
|
const words = Utf8.parse(content);
|
|
const words = Utf8.parse(content);
|
|
@@ -10,16 +12,35 @@ export const getBase64 = (content: string): string => {
|
|
return base64Str;
|
|
return base64Str;
|
|
};
|
|
};
|
|
|
|
|
|
-export const getAES = (content: string): string => {
|
|
|
|
- const KEY = '1234567890123456';
|
|
|
|
- const IV = '1234567890123456';
|
|
|
|
|
|
+export const AESEncode = (content: string): string => {
|
|
|
|
+ const KEY = 'Qmth87863577qmth';
|
|
|
|
+ // const IV = '1234567890123456';
|
|
|
|
|
|
const key = Utf8.parse(KEY);
|
|
const key = Utf8.parse(KEY);
|
|
- const iv = Utf8.parse(IV);
|
|
|
|
- const encrypted = AES.encrypt(content, key, { iv });
|
|
|
|
|
|
+ // const iv = Utf8.parse(IV);
|
|
|
|
+ const encrypted = AES.encrypt(content, key, {
|
|
|
|
+ // iv,
|
|
|
|
+ mode: ECB,
|
|
|
|
+ padding: Pkcs7,
|
|
|
|
+ });
|
|
return encrypted.toString();
|
|
return encrypted.toString();
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+export const AESDecode = (content: string): string => {
|
|
|
|
+ const KEY = 'Qmth87863577qmth';
|
|
|
|
+ // const IV = "1234567890123456";
|
|
|
|
+
|
|
|
|
+ const key = Utf8.parse(KEY);
|
|
|
|
+
|
|
|
|
+ // const iv = Utf8.parse(IV);
|
|
|
|
+ const decrypted = AES.decrypt(content, key, {
|
|
|
|
+ // iv: iv,
|
|
|
|
+ mode: ECB,
|
|
|
|
+ padding: Pkcs7,
|
|
|
|
+ });
|
|
|
|
+ return decrypted.toString(Utf8);
|
|
|
|
+};
|
|
|
|
+
|
|
type AuthType = 'token' | 'secret';
|
|
type AuthType = 'token' | 'secret';
|
|
interface AuthInfo {
|
|
interface AuthInfo {
|
|
uri: string;
|
|
uri: string;
|