rcrypto 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/RCrypto/encode.rb +32 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd47d422f2107d9768a64002fd8cf3505606d508342d0415a3f336312f439d6d
|
4
|
+
data.tar.gz: a5f96d052d0905fc4a2eb2049a81124c6f01790897de453ac7ce40a1652ba08e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a72aaf955d5b197740740e0da62464470605aad88727ec3c6fa6ede4cf243de91ea3a2ca79fbf47438918f60ec5b6cfc54c07c6c54a9f919cabdb214b14d0dc
|
7
|
+
data.tar.gz: 833d6bcb41672b5d5e5495ccbf4ea7383c67d8b2617f8c76a0a3fd9af04c93bfe9f436af432043d9ce77fbcef65cab12145fc5ffc5f4048567cde76e31ff1047
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# lib/RCrypto/encode.rb
|
2
|
+
|
3
|
+
module RCrypto
|
4
|
+
module Encode
|
5
|
+
def self.xor_encrypt(text, key)
|
6
|
+
text.bytes.map.with_index do |byte, i|
|
7
|
+
(byte ^ key.bytes[i % key.length]).chr
|
8
|
+
end.join
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.base64_custom_encode(text)
|
12
|
+
Base64.strict_encode64(text)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.caesar_cipher_encrypt(text, shift)
|
16
|
+
text.chars.map do |char|
|
17
|
+
if char.match(/[a-zA-Z]/)
|
18
|
+
base = char =~ /[a-z]/ ? 'a'.ord : 'A'.ord
|
19
|
+
((char.ord - base + shift) % 26 + base).chr
|
20
|
+
else
|
21
|
+
char
|
22
|
+
end
|
23
|
+
end.join
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.add_fake_token(text)
|
27
|
+
fake_token = "$" + SecureRandom.alphanumeric(10)
|
28
|
+
insertion_point = SecureRandom.random_number(text.length)
|
29
|
+
text.insert(insertion_point, fake_token)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rcrypto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MAVEN
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: digest
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- README.md
|
106
106
|
- lib/RCrypto.rb
|
107
107
|
- lib/RCrypto/decode.rb
|
108
|
+
- lib/RCrypto/encode.rb
|
108
109
|
- lib/RCrypto/version.rb
|
109
110
|
- spec/rcrypto_spec.rb
|
110
111
|
- spec/spec_helper.rb
|