cipherworld-amelia2021 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/assets/llc.txt +98 -0
- data/assets/lnc.txt +98 -0
- data/bin/cipherworld-amelia2021 +42 -0
- data/lib/cipherworld-amelia2021.rb +50 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: caf315ba572bebe826ebcfabd510dd725135fd2a13d3dbebd9aa8e48fb50d694
|
4
|
+
data.tar.gz: 6d3563d51e4b2d13d0b829d4e135d5442edf94309f582b67002bd97922765b26
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bd977ae91e9c97d65364ccdfcf947b976c0be6e2d7b2f18acd23f588429a425b50ae79db86031083da054bf5c63c063a4c6a90cb09c12af82e167ab52eb24345
|
7
|
+
data.tar.gz: 50eeb5f05af0cb48f785cbc9f67a0dc3809339262e1be99b0ddf1d8a7b9c94b9dae53e75ced4a574b95d925b133d2c45cbd0b53847d890dbcec173a7614661b9
|
data/assets/llc.txt
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
character, value
|
2
|
+
, m
|
3
|
+
a, X
|
4
|
+
b, p
|
5
|
+
c, M
|
6
|
+
d, *
|
7
|
+
e, D
|
8
|
+
f, 3
|
9
|
+
g, £
|
10
|
+
h, §
|
11
|
+
i, t
|
12
|
+
j, Y
|
13
|
+
k, y
|
14
|
+
l, 7
|
15
|
+
m, .
|
16
|
+
n, w
|
17
|
+
o, !
|
18
|
+
p, %
|
19
|
+
q, g
|
20
|
+
r, A
|
21
|
+
s, u
|
22
|
+
t, 2
|
23
|
+
u, J
|
24
|
+
v, 9
|
25
|
+
w, _
|
26
|
+
x, @
|
27
|
+
y, [
|
28
|
+
z, L
|
29
|
+
A, h
|
30
|
+
B, q
|
31
|
+
C, 0
|
32
|
+
D, G
|
33
|
+
E, j
|
34
|
+
F, ^
|
35
|
+
G, Z
|
36
|
+
H, ]
|
37
|
+
I, I
|
38
|
+
J, |
|
39
|
+
K, >
|
40
|
+
L, B
|
41
|
+
M, c
|
42
|
+
N, i
|
43
|
+
O, e
|
44
|
+
P, ;
|
45
|
+
Q, ~
|
46
|
+
R, :
|
47
|
+
S, P
|
48
|
+
T, ±
|
49
|
+
U, k
|
50
|
+
V, S
|
51
|
+
W, &
|
52
|
+
X, +
|
53
|
+
Y, l
|
54
|
+
Z, a
|
55
|
+
!,
|
56
|
+
@, R
|
57
|
+
£, ,
|
58
|
+
$, }
|
59
|
+
%, n
|
60
|
+
^, z
|
61
|
+
&, F
|
62
|
+
*, 8
|
63
|
+
(, C
|
64
|
+
), -
|
65
|
+
-, ?
|
66
|
+
_, x
|
67
|
+
=, 5
|
68
|
+
+, U
|
69
|
+
[, K
|
70
|
+
], v
|
71
|
+
{, =
|
72
|
+
}, <
|
73
|
+
;, 1
|
74
|
+
:, d
|
75
|
+
', {
|
76
|
+
", N
|
77
|
+
\, O
|
78
|
+
|, b
|
79
|
+
,, $
|
80
|
+
., Q
|
81
|
+
<, H
|
82
|
+
>, (
|
83
|
+
/, \
|
84
|
+
?, 4
|
85
|
+
`, )
|
86
|
+
~, s
|
87
|
+
§, 6
|
88
|
+
±, V
|
89
|
+
1, o
|
90
|
+
2, W
|
91
|
+
3, "
|
92
|
+
4, E
|
93
|
+
5, '
|
94
|
+
6, r
|
95
|
+
7, /
|
96
|
+
8, `
|
97
|
+
9, f
|
98
|
+
0, T
|
data/assets/lnc.txt
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
character, value
|
2
|
+
, 1
|
3
|
+
a, 2
|
4
|
+
b, 3
|
5
|
+
c, 4
|
6
|
+
d, 5
|
7
|
+
e, 6
|
8
|
+
f, 7
|
9
|
+
g, 8
|
10
|
+
h, 9
|
11
|
+
i, 10
|
12
|
+
j, 11
|
13
|
+
k, 12
|
14
|
+
l, 13
|
15
|
+
m, 14
|
16
|
+
n, 15
|
17
|
+
o, 16
|
18
|
+
p, 17
|
19
|
+
q, 18
|
20
|
+
r, 19
|
21
|
+
s, 20
|
22
|
+
t, 21
|
23
|
+
u, 22
|
24
|
+
v, 23
|
25
|
+
w, 24
|
26
|
+
x, 25
|
27
|
+
y, 26
|
28
|
+
z, 27
|
29
|
+
A, 28
|
30
|
+
B, 29
|
31
|
+
C, 30
|
32
|
+
D, 31
|
33
|
+
E, 32
|
34
|
+
F, 33
|
35
|
+
G, 34
|
36
|
+
H, 35
|
37
|
+
I, 36
|
38
|
+
J, 37
|
39
|
+
K, 38
|
40
|
+
L, 39
|
41
|
+
M, 40
|
42
|
+
N, 41
|
43
|
+
O, 42
|
44
|
+
P, 43
|
45
|
+
Q, 44
|
46
|
+
R, 45
|
47
|
+
S, 46
|
48
|
+
T, 47
|
49
|
+
U, 48
|
50
|
+
V, 49
|
51
|
+
W, 50
|
52
|
+
X, 51
|
53
|
+
Y, 52
|
54
|
+
Z, 53
|
55
|
+
!, 54
|
56
|
+
@, 55
|
57
|
+
£, 56
|
58
|
+
$, 57
|
59
|
+
%, 58
|
60
|
+
^, 59
|
61
|
+
&, 60
|
62
|
+
*, 61
|
63
|
+
(, 62
|
64
|
+
), 63
|
65
|
+
-, 64
|
66
|
+
_, 65
|
67
|
+
=, 66
|
68
|
+
+, 67
|
69
|
+
[, 68
|
70
|
+
], 69
|
71
|
+
{, 70
|
72
|
+
}, 71
|
73
|
+
;, 72
|
74
|
+
:, 73
|
75
|
+
', 74
|
76
|
+
", 75
|
77
|
+
\, 76
|
78
|
+
|, 77
|
79
|
+
,, 78
|
80
|
+
., 79
|
81
|
+
<, 80
|
82
|
+
>, 81
|
83
|
+
/, 82
|
84
|
+
?, 83
|
85
|
+
`, 84
|
86
|
+
~, 85
|
87
|
+
§, 86
|
88
|
+
±, 87
|
89
|
+
1, 88
|
90
|
+
2, 89
|
91
|
+
3, 90
|
92
|
+
4, 91
|
93
|
+
5, 92
|
94
|
+
6, 93
|
95
|
+
7, 94
|
96
|
+
8, 95
|
97
|
+
9, 96
|
98
|
+
0, 97
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'cipherworld-amelia2021'
|
4
|
+
|
5
|
+
cipher, method, filename, key = ARGV
|
6
|
+
|
7
|
+
lnc_dict_path = File.join(File.dirname(__FILE__), "../assets/lnc.txt")
|
8
|
+
llc_dict_path = File.join(File.dirname(__FILE__), "../assets/llc.txt")
|
9
|
+
|
10
|
+
# Handle bad command line arguments
|
11
|
+
|
12
|
+
if ['ln', 'll'].none? cipher
|
13
|
+
puts "Unknown Cipher: #{cipher}. Available ciphers are ln and ll"
|
14
|
+
return
|
15
|
+
end
|
16
|
+
|
17
|
+
if ['enc', 'dec'].none? method
|
18
|
+
puts "Unknown Action: #{method}. Available actions are enc and dec"
|
19
|
+
return
|
20
|
+
end
|
21
|
+
|
22
|
+
unless File.file? filename
|
23
|
+
puts "No file found ./#{filename}."
|
24
|
+
return
|
25
|
+
end
|
26
|
+
|
27
|
+
key = key.to_i ||= 0
|
28
|
+
|
29
|
+
# Main Script
|
30
|
+
|
31
|
+
newname = method == 'enc' ? "#{filename}.enc" : "#{filename.sub(/\.enc$/, '')}"
|
32
|
+
text = File.read filename
|
33
|
+
|
34
|
+
if cipher == 'ln'
|
35
|
+
lnc = Cipher::LetterNumber.new(charset: lnc_dict_path, key: key)
|
36
|
+
result = method == 'enc' ? lnc.encrypt(text) : lnc.decrypt(text)
|
37
|
+
else
|
38
|
+
llc = Cipher::LetterLetter.new(charset: llc_dict_path)
|
39
|
+
result = method == 'enc' ? llc.encrypt(text) : llc.decrypt(text)
|
40
|
+
end
|
41
|
+
|
42
|
+
File.write(newname, result)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Cipher
|
2
|
+
class LetterNumber
|
3
|
+
def initialize(args)
|
4
|
+
@charset = {}
|
5
|
+
@key = args[:key]
|
6
|
+
|
7
|
+
File.open(args[:charset], 'r') do |f|
|
8
|
+
f.readlines.map(&:chomp).each { |str| @charset[str[0]] = str[str.rindex(",") + 2..-1] }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def encrypt plaintext
|
13
|
+
plaintext.chars.map do |char|
|
14
|
+
"#{ (@charset[char].to_i + @key) % 99 }"
|
15
|
+
.sub(/^[0-9]{1}$/) { |num| "0#{num}" }
|
16
|
+
end.join
|
17
|
+
end
|
18
|
+
|
19
|
+
def decrypt ciphertext
|
20
|
+
plaintext = ""
|
21
|
+
|
22
|
+
ciphertext.chars.each_slice(2).map(&:join).each do |char|
|
23
|
+
char = char[1..-1] if char[0] == "0"
|
24
|
+
char = @charset.invert[(( char.to_i - @key ) % 99 ).to_s ]
|
25
|
+
plaintext << char
|
26
|
+
end
|
27
|
+
|
28
|
+
plaintext
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class LetterLetter
|
33
|
+
def initialize(args)
|
34
|
+
@charset = {}
|
35
|
+
@key = args[:key]
|
36
|
+
|
37
|
+
File.open(args[:charset], 'r') do |f|
|
38
|
+
f.readlines.map(&:chomp).each { |str| @charset[str[0]] = str[str.rindex(",") + 2..-1] }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def encrypt plaintext
|
43
|
+
plaintext.chars.map { |char| @charset[char] }.join
|
44
|
+
end
|
45
|
+
|
46
|
+
def decrypt ciphertext
|
47
|
+
ciphertext.chars.map { |char| @charset.invert[char] }.join
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cipherworld-amelia2021
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Amelia Scott
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-15 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A gem for encrypting and decrypting strings
|
14
|
+
email: abc.scott@gmail.com
|
15
|
+
executables:
|
16
|
+
- cipherworld-amelia2021
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- assets/llc.txt
|
21
|
+
- assets/lnc.txt
|
22
|
+
- bin/cipherworld-amelia2021
|
23
|
+
- lib/cipherworld-amelia2021.rb
|
24
|
+
homepage:
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubygems_version: 3.2.15
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: Cipherworld
|
47
|
+
test_files: []
|