UI: Create password based encryptor using crypto-js library

Password based encryptor is required for configuration encryption
This commit is contained in:
vakarisz 2022-06-28 16:05:49 +03:00
parent 8cb9c4463a
commit 69ca2d541d
3 changed files with 23 additions and 0 deletions

View File

@ -20,6 +20,7 @@
"bootstrap": "^4.5.3",
"classnames": "^2.3.1",
"core-js": "^3.18.2",
"crypto-js": "^4.1.1",
"d3": "^5.14.1",
"downloadjs": "^1.4.7",
"fetch": "^1.1.0",
@ -4191,6 +4192,11 @@
"semver": "bin/semver"
}
},
"node_modules/crypto-js": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz",
"integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw=="
},
"node_modules/css-loader": {
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/css-loader/-/css-loader-6.7.1.tgz",
@ -19166,6 +19172,11 @@
}
}
},
"crypto-js": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz",
"integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw=="
},
"css-loader": {
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/css-loader/-/css-loader-6.7.1.tgz",

View File

@ -76,6 +76,7 @@
"bootstrap": "^4.5.3",
"classnames": "^2.3.1",
"core-js": "^3.18.2",
"crypto-js": "^4.1.1",
"d3": "^5.14.1",
"downloadjs": "^1.4.7",
"fetch": "^1.1.0",

View File

@ -0,0 +1,11 @@
import AES from 'crypto-js/aes';
import Utf8 from 'crypto-js/enc-utf8';
export function encryptText(content: string, password: string): string {
return AES.encrypt(content, password).toString();
}
export function decryptText(ciphertext: string, password: string): string {
let bytes = AES.decrypt(ciphertext, password);
return bytes.toString(Utf8);
}