-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutil.js
40 lines (28 loc) · 983 Bytes
/
util.js
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
const CryptoJs=require("crypto-js");
const cloudinary = require('cloudinary').v2;
const cloudinaryConfiguration=require('./CloudinaryConfiguration');
const symmetricKey='secret key 123';
exports.encrypt=function(text){
return CryptoJs.AES.encrypt(text, symmetricKey).toString();
}
exports.decrypt=function(text){
var bytes=CryptoJs.AES.decrypt(text, symmetricKey);
return bytes.toString(CryptoJs.enc.Utf8);
}
exports.delete_images=function(image_urls_for_delete){
cloudinary.config({
cloud_name: cloudinaryConfiguration.getCloudName(),
api_key: cloudinaryConfiguration.getApiKey(),
api_secret: cloudinaryConfiguration.getApiSecret()
});
const promises=Object.keys(image_urls_for_delete).map(
key=>{
cloudinary.uploader.destroy(image_urls_for_delete[key]);
});
promises.forEach(async(promise, i) => {
await(promise);
}
);
console.log(" deleted "+image_urls_for_delete);
return "ok";
}