crypto-core 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -4
- package/dist/index.js +20 -28
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -35,7 +35,11 @@ Take into account multiple character chain.
|
|
|
35
35
|
so this code works for channels with french, spanish, deutsch, latin accents and lots of character with variant obselette.
|
|
36
36
|
Do not take into account the Greek accents, I do not take into account also all the Chinese, Japanese and Korean accents (Madarain, Katakana, etc ....)
|
|
37
37
|
|
|
38
|
+
## Changelog
|
|
38
39
|
|
|
40
|
+
### v1.0.1
|
|
41
|
+
- Fixed decryption bug with negative modulo operations
|
|
42
|
+
- Improved handling of character position in digest calculation
|
|
39
43
|
|
|
40
44
|
|
|
41
45
|
## Installation
|
|
@@ -67,15 +71,15 @@ const cryptoCore = require("crypto-core")
|
|
|
67
71
|
const notCoded = "bonjour"
|
|
68
72
|
const otherNotCoded = "bonjour je suis ce que je suis et toi"
|
|
69
73
|
|
|
70
|
-
const coded = cryptoCore.
|
|
74
|
+
const coded = cryptoCore.coreEncode(notCoded)
|
|
71
75
|
// coded -> oAytxCy
|
|
72
|
-
const otherCoded = cryptoCore.
|
|
76
|
+
const otherCoded = cryptoCore.coreEncode(otherNotCoded)
|
|
73
77
|
// coded -> S42X162 TN 01OX TV 7ÄV 0V 9ÄZ9 VÀ À5Z
|
|
74
78
|
|
|
75
|
-
const codedWithDigest = cryptoCore.
|
|
79
|
+
const codedWithDigest = cryptoCore.coreEncode(notCoded, 8)
|
|
76
80
|
// coded -> qCAvzEA
|
|
77
81
|
|
|
78
|
-
const decode = cryptoCore.
|
|
82
|
+
const decode = cryptoCore.coreDecode(coded)
|
|
79
83
|
// coded -> bonjour
|
|
80
84
|
|
|
81
85
|
|
package/dist/index.js
CHANGED
|
@@ -5,22 +5,18 @@ var initDigest = 6;
|
|
|
5
5
|
function coreEncode(key_word, digest) {
|
|
6
6
|
if (digest === void 0) { digest = initDigest; }
|
|
7
7
|
var key = key_word.length;
|
|
8
|
-
var
|
|
8
|
+
var currentDigest = digest;
|
|
9
9
|
var key_word_encoded = key_word.split('').map(function (value) {
|
|
10
10
|
if (value === ' ')
|
|
11
11
|
return ' ';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
else {
|
|
21
|
-
return initData[index % initData.length];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
12
|
+
var charIndex = initData.indexOf(value);
|
|
13
|
+
if (charIndex === -1)
|
|
14
|
+
return value; // Caractère non trouvé
|
|
15
|
+
var index = charIndex + key + currentDigest;
|
|
16
|
+
currentDigest--; // Décrémenter pour le prochain caractère
|
|
17
|
+
// Gestion correcte du modulo (toujours positif)
|
|
18
|
+
index = ((index % initData.length) + initData.length) % initData.length;
|
|
19
|
+
return initData[index];
|
|
24
20
|
}).join('');
|
|
25
21
|
return key_word_encoded;
|
|
26
22
|
}
|
|
@@ -28,23 +24,19 @@ exports.coreEncode = coreEncode;
|
|
|
28
24
|
function coreDecode(key_word, digest) {
|
|
29
25
|
if (digest === void 0) { digest = initDigest; }
|
|
30
26
|
var key = key_word.length;
|
|
31
|
-
var
|
|
32
|
-
var
|
|
27
|
+
var currentDigest = digest;
|
|
28
|
+
var key_word_decoded = key_word.split('').map(function (value) {
|
|
33
29
|
if (value === ' ')
|
|
34
30
|
return ' ';
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
else {
|
|
44
|
-
return initData[index % initData.length];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
31
|
+
var charIndex = initData.indexOf(value);
|
|
32
|
+
if (charIndex === -1)
|
|
33
|
+
return value; // Caractère non trouvé
|
|
34
|
+
var index = charIndex - key - currentDigest;
|
|
35
|
+
currentDigest--; // Décrémenter pour le prochain caractère
|
|
36
|
+
// Gestion correcte du modulo (toujours positif)
|
|
37
|
+
index = ((index % initData.length) + initData.length) % initData.length;
|
|
38
|
+
return initData[index];
|
|
47
39
|
}).join('');
|
|
48
|
-
return
|
|
40
|
+
return key_word_decoded;
|
|
49
41
|
}
|
|
50
42
|
exports.coreDecode = coreDecode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crypto-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Symmetric key encryption module. varying according to the size of the chain of characters and also of the digest. Robust, stable.",
|
|
5
5
|
"readme": "# A Node.js module for Symmetric key encryption module. varying according to the size of the chain of characters and also of the digest. Robust, stable. ",
|
|
6
6
|
"readmeFilename": "README.md",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
|
-
"url": "
|
|
23
|
+
"url": "git+https://github.com/rochelryu/crypto-core.git"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
26
|
"crypto",
|