Skip to content

Commit 17d934f

Browse files
committed
fixes for forge fileencryption examples made
1 parent 2e50e01 commit 17d934f

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/objectOriented/ExampleFileEncryption.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ try {
9898
// create random initialization vector
9999
let iv = forge.random.getBytesSync(16);
100100
// read file and put content into a node Buffer
101-
let input = fs.readFileSync("file.txt");
101+
let input = fs.readFileSync("file2.txt");
102102
// encrypt file content and write encrypted file content to file
103103
let encrypted = encryptFileContent(input, key, iv);
104-
fs.writeFileSync("file.enc.txt", encrypted);
104+
fs.writeFileSync("file2.enc.txt", encrypted);
105105
// decrypt file content and write dercypted file content to file
106106
let decrypted = decryptFileContent(encrypted, key, iv);
107-
fs.writeFileSync("file.dec.txt", decrypted);
107+
fs.writeFileSync("file2.dec.txt", decrypted);
108108

109109
logger.info(
110110
"Decrypted file content and original file content are the same: %s",

test/objectOriented/ExampleFileEncryption.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ var chai = require("chai"),
66
fs = require("fs"),
77
chaiFiles = require("chai-files");
88

9-
let testFile = fs.readFileSync("file.txt", { encoding: "binary" });
10-
let testFileEnc = fs.readFileSync("file.enc.txt", { encoding: "binary" });
9+
let testFile = fs.readFileSync("file2.txt", { encoding: "binary" });
10+
let testFileEnc = fs.readFileSync("file2.enc.txt", { encoding: "binary" });
1111
let testIv = forge.random.getBytesSync(16);
1212
let testKey = forge.random.getBytesSync(32);
13-
let testFileDec = fs.readFileSync("file.dec.txt", { encoding: "binary" });
13+
let testFileDec = fs.readFileSync("file2.dec.txt", { encoding: "binary" });
1414

1515
describe("fileencrypt forge Test runs", function() {
1616
it("calling function without iv, should throw an error", function() {
@@ -29,10 +29,10 @@ describe("fileencrypt forge Test runs", function() {
2929
.to.throw();
3030
});
3131
it("running code, should create a file 'file.enc.txt'", function() {
32-
chai.expect(chaiFiles.file("file.enc.txt")).to.exist;
32+
chai.expect(chaiFiles.file("file2.enc.txt")).to.exist;
3333
});
3434
it("running code, should create a file 'file.dec.txt'", function() {
35-
chai.expect(chaiFiles.file("file.dec.txt")).to.exist;
35+
chai.expect(chaiFiles.file("file2.dec.txt")).to.exist;
3636
});
3737

3838
it("decrypted file should be equal to original file", function() {

0 commit comments

Comments
 (0)