Skip to content

Commit 10658ab

Browse files
feat: Add ARMON-64
1 parent 14281ef commit 10658ab

File tree

5 files changed

+92
-2
lines changed

5 files changed

+92
-2
lines changed

docs/ciphers/armon64.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# ARMON-64
2+
3+
> A widely unknown cipher, mostly seen on "underground" sites and forums.
4+
Neither the origin nor the creator are known. It has large similarities
5+
to [AER-256](./aer256.md).
6+
7+
## Cipher behavior information
8+
9+
* Case sensitive? ✓
10+
* Deterministic? ✓
11+
* Alphabet: ```!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ``` (All Unicode Characters using only 2 bytes (U+0000 - U+00FF)
12+
* Characters not in alphabet will: **throw an error**
13+
14+
## Default options object
15+
16+
```
17+
const options = {
18+
key: '' // Must be at least 3 characters long!
19+
}
20+
```
21+
22+
## Usage
23+
24+
### Encoding
25+
26+
#### Default
27+
28+
```
29+
import armon64 from 'cipher-collection'
30+
31+
32+
console.log(armon64.encode('hey', { key: 'ABCDEF' })) // 1007.3509783549783
33+
```
34+
35+
### Decoding
36+
37+
#### Default
38+
39+
```
40+
import armon64 from 'cipher-collection'
41+
42+
43+
console.log(armon64.decode('1007.3509783549783', { key: 'ABCDEF' })) // hey
44+
```

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
* [Multiplicative cipher](./ciphers/multiplicative.md)
2020
* [Affine](./ciphers/affine.md)
2121
* [AER-256](./ciphers/aer256.md)
22-
22+
* [ARMON-64](./ciphers/armon64.md)

src/armon64.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import base from './helpers/aerArmonBase'
2+
3+
const encode = (input, options = {}) => {
4+
options = { ...DEFAULT_OPTIONS, ...options }
5+
return base.encode(input, options)
6+
}
7+
8+
const decode = (input, options = {}) => {
9+
options = { ...DEFAULT_OPTIONS, ...options }
10+
return base.decode(input, options)
11+
}
12+
13+
const DEFAULT_OPTIONS = {
14+
key: '',
15+
failOnUnknownCharacter: true
16+
}
17+
18+
export default {
19+
encode,
20+
decode
21+
}

src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import wolfenbuetteler from './wolfenbuetteler'
99
import multiplicative from './multiplicative'
1010
import affine from './affine'
1111
import aer256 from './aer256'
12+
import armon64 from './armon64'
1213

1314
export default {
1415
rot,
@@ -21,5 +22,6 @@ export default {
2122
wolfenbuetteler,
2223
multiplicative,
2324
affine,
24-
aer256
25+
aer256,
26+
armon64
2527
}

test/armon64.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import armon64 from 'armon64'
2+
3+
describe('encoding', () => {
4+
test('default', () => {
5+
expect(() => { armon64.encode('1007.3509783549783') }).toThrowError('Key is too short! It must be at least 3 characters')
6+
})
7+
test('with key', () => {
8+
expect(armon64.encode('hey', { key: 'ABCDEF' })).toBe('1007.3509783549783')
9+
expect(armon64.encode('hey!*A', { key: 'ABCDEF*' })).toBe('257752.02713419913+-40.0634632034632')
10+
expect(armon64.encode('hey!*A!Ü!Ü!Ü!', { key: 'ABCDEF*' })).toBe('257752.02713419913+104300.3085800866+83571.0731861472+-41.65071861471861')
11+
})
12+
})
13+
14+
describe('decoding', () => {
15+
test('default', () => {
16+
expect(() => { armon64.decode('1432.382960035134') }).toThrowError('Key is too short! It must be at least 3 characters')
17+
})
18+
test('with key', () => {
19+
expect(armon64.decode('1007.3509783549783', { key: 'ABCDEF' })).toBe('hey')
20+
expect(armon64.decode('257752.02713419913+-40.0634632034632', { key: 'ABCDEF*' })).toBe('hey!*A')
21+
expect(armon64.decode('257752.02713419913+104300.3085800866+83571.0731861472+-41.65071861471861', { key: 'ABCDEF*' })).toBe('hey!*A!Ü!Ü!Ü!')
22+
})
23+
})

0 commit comments

Comments
 (0)