ఫైళ్లను ఎన్‌క్రిప్ట్/డీక్రిప్ట్ చేయడం గురించి

sendfilesencrypted.comలో మేము మీ ఫైల్‌ల భద్రత గురించి శ్రద్ధ వహిస్తాము మరియు ఆన్‌లైన్‌లో ఫైల్‌లను భాగస్వామ్యం చేయడంలో మీ అనుభవం మరియు సురక్షితంగా ఉండాలని మేము కోరుకుంటున్నాము.

అందుకే మేము ఉచిత ఫైల్ ఎన్‌క్రిప్షన్ కార్యాచరణను అమలు చేసాము.

మీరు Sendfilesencrypted.comలో భాగస్వామ్యం చేసే అన్ని ఫైల్‌లు మా సర్వర్‌లకు అప్‌లోడ్ చేయబడే ముందు గుప్తీకరించబడతాయి, ఇది మీరు భాగస్వామ్యం చేసే ప్రతి ఫైల్‌కి భద్రతా పొరను జోడిస్తుంది, వాటిని యాక్సెస్ చేయకుండా ఎవరైనా లేదా ముప్పును నిరోధిస్తుంది.

అదే విధంగా, మీ ఫైల్‌లను అప్‌లోడ్ చేస్తున్నప్పుడు మీరు అందించిన పాస్‌వర్డ్‌ని ఉపయోగించి మీ అన్ని ఫైల్‌లు మీ బ్రౌజర్‌లో డీక్రిప్ట్ చేయబడతాయి, దాడి చేసే వ్యక్తి మీ ఫైల్‌లను యాక్సెస్ చేస్తే, అవి పూర్తిగా ఎన్‌క్రిప్ట్ చేయబడతాయని ఇది నిర్ధారిస్తుంది.

మీ ఫైల్‌లను అప్‌లోడ్ చేయడానికి మరియు మా సర్వర్‌లలో నిల్వ చేయడానికి ముందు మేము వాటిని ఎలా గుప్తీకరిస్తాము.

కోడ్ మీ ఫైల్‌లను బహుళ చిన్న ఫైల్‌లుగా విభజిస్తుంది, ప్రతి ముక్క మీరు వాటిని అప్‌లోడ్ చేయడానికి ఉపయోగించిన పాస్‌వర్డ్‌ని మరియు ప్రతి ఫైల్‌ల సమూహానికి ప్రత్యేకమైన కోడ్‌ని ఉపయోగించి గుప్తీకరించబడుతుంది, ఇది మీ ఫైల్‌లకు మరింత ఎక్కువ భద్రతను అందిస్తుంది. ఈ ప్రక్రియ తర్వాత గుప్తీకరించిన ఫైల్ యొక్క ప్రతి భాగం అప్‌లోడ్ చేయబడుతుంది మరియు మా సర్వర్‌లో నిల్వ చేయబడుతుంది. డెవలపర్‌లమైన మేము కూడా మీ ఫైల్‌లను యాక్సెస్ చేయలేమని ఇది నిర్ధారిస్తుంది.

/*
In this code you will find how I encrypt files (using CryptoJS) before uploading to the server, this is the steps I follow:
1. Calculate the size of all the files I want to upload, I will use this number to stop my recursive function
2. I slice every file in chunks of max 5MB, if the final value of chunkEnd is equals to the current file size then I jump to the next file passing the new index as indexFile + 1
3. I read the file slice using FileReader, then I start the encryption of the arrayBuffer content, passing the password the user provide.
4. I create a new Blob using the encrypted string and pass it to my custom Ajax function to upload it to the server, once the encrypted chunk is stored I call the recursive function again.
*/
var chunkStart = 0;
var chunkEnd = 0;
var chunkCounter = 0;
var files = $(this)[0].files;
var totalSize = files.map(
function (item) {
return item.size
}
).reduce(
function (a, b) {
return a + b
}
);
uploadChunk(totalSize, 0, chunkStart, chunkEnd, chunkCounter);
// I will use this function to encrypt and upload every file slice
function uploadChunk(totalSize, fileIndex, chunkStart, chunkEnd, chunkCounter) {
if (fileIndex >= files.length) {
return;
}
var currentFile = files[fileIndex];
var chunkSize = 6000000;
var fileSize = currentFile.size;
if (chunkEnd >= fileSize) {
return uploadChunk(totalSize, fileIndex + 1, 0, 0, 0);
}
chunkEnd = Math.min(chunkStart + chunkSize, fileSize);
var reader = new FileReader();
reader.onload = function () {
var secret_key = CryptoJS.PBKDF2(
password,
CryptoJS.enc.Hex.parse(`${file_key}`),
{
keySize: 512 / 32,
iterations: 20000
}
);
var ivString = generateRandom(chars=120);
var iv = CryptoJS.enc.Hex.parse(`${ivString}`);
var wordArray = CryptoJS.lib.WordArray.create(reader.result);
var encrypted = CryptoJS.AES.encrypt(wordArray, secret_key, {
iv: iv
}).toString();
var encryptedFile = new Blob([`${ivString}:${encrypted}`]);
// PromiseRequestFunction is a custom function I use to make ajax requests, I'm passing the blob files as parameter
var p = PromiseRequestFunction(
...
[encryptedFile]
);
p.then(
function () {
chunkStart += chunkSize;
chunkCounter += 1;
uploadChunk(totalSize, fileIndex, chunkStart, chunkEnd, chunkCounter);
},
function () {
}
);
}
reader.readAsArrayBuffer(currentFile.slice(chunkStart, chunkEnd));
}
view raw encrypt.js hosted with ❤ by GitHub

మీ ఫైల్‌లను ఎలా డీక్రిప్ట్ చేయాలో ఇప్పుడు నేను మీకు చూపిస్తాను.

ప్రతి అసలు ఫైల్ గుప్తీకరించిన ఫైల్‌ల యొక్క అనేక ముక్కలుగా మారిందని గుర్తుంచుకోండి, అవి మా సర్వర్‌లో నిల్వ చేయబడతాయి. ప్రతి ముక్క బ్రౌజర్‌లో డౌన్‌లోడ్ చేయబడుతుంది, ఆపై మీరు నమోదు చేసిన పాస్‌వర్డ్ మరియు ఫైల్ బ్లాక్ యొక్క ప్రత్యేక కోడ్ ప్రతి భాగాన్ని డీక్రిప్ట్ చేయడానికి ఉపయోగించబడతాయి, ఇది మీ అసలు ఫైల్‌లోని అనేక ఇతర డీక్రిప్ట్ చేసిన ముక్కలకు చేరి, ఆపై సృష్టించి, డౌన్‌లోడ్ చేయండి అసలు ఫైల్.

/*
In this code you will find how I decrypt blob files (using CryptoJS)
1. I need the filename and get the blobURLs (for this example I will be using a hardcoded blobURLs, but in my case I'm getting that info from a previous ajax call)
// I start the recursive function. Note the the first paramater will contains the decrypted blobs.
2. I check if the index is greated than my blobURLs length, so I can know when to stop the recursive function and create the download link.
3. I get the blob file using XMLHttpRequest and passing the blobURL.
4. I read the blob content using FileReader, note that I'm using reader.readAsText because I'm getting a base64 text.
5. I decrypt the blob text content, using the password passed by the user.
6. I parse the wordArray and create a new Blob with the result that is stored in the blobs array and I call the recursive function again.
*/
var filename = 'my_awesome_picture.png';
var blobURLS = ['https://sfo.to/blob_1', 'https://sfo.to/blob_2', ...]
getBlob([], blobURLs, 0, filename);
function getBlob(blobs, urls, index, filename) {
if (index >= urls.length) {
var blob = new Blob(blobs);
var url = window.URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = filename;
a.click();
} else {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
var reader = new FileReader();
reader.onload = function () {
var secret_key = secret_key = CryptoJS.PBKDF2(
password,
CryptoJS.enc.Hex.parse(`${file_key}`),
{
keySize: 512 / 32,
iterations: 20000
}
);
var encryptedParts = reader.result.split(':');
var iv = CryptoJS.enc.Hex.parse(`${encryptedParts[0]}`);
encryptedParts.shift();
var decrypted = CryptoJS.AES.decrypt(encryptedParts.join(), secret_key, {
iv: iv
});
var typedArray = convertWordArrayToUint8Array(decrypted);
blobs.push(new Blob([typedArray]));
getBlob(blobs, urls, index + 1, filename);
};
reader.readAsText(this.response);
}
}
xhr.open('POST', `${urls[index]}`);
xhr.responseType = 'blob';
xhr.send();
}
}
function convertWordArrayToUint8Array(wordArray) {
var arrayOfWords = wordArray.hasOwnProperty("words") ? wordArray.words : [];
var length = wordArray.hasOwnProperty("sigBytes") ? wordArray.sigBytes : arrayOfWords.length * 4;
var uInt8Array = new Uint8Array(length), index = 0, word, i;
for (i = 0; i < length; i++) {
word = arrayOfWords[i];
uInt8Array[index++] = word >> 24;
uInt8Array[index++] = (word >> 16) & 0xff;
uInt8Array[index++] = (word >> 8) & 0xff;
uInt8Array[index++] = word & 0xff;
}
return uInt8Array;
}
view raw decrypt.js hosted with ❤ by GitHub
పాస్‌వర్డ్ లేకుండా, మీ ఫైల్‌లను డీక్రిప్ట్ చేయడం మాకు అసాధ్యం మరియు మీరు చదవడం సాధ్యం కాని పాడైన ఫైల్‌ను పొందుతారు.

మీరు చదివినవి నచ్చిందా? ఇప్పుడు గుప్తీకరించిన ఫైల్‌లను పంపండి