rcrypto 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/RCrypto/encode.rb +32 -0
  3. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e23fe6da3f338421ca9ee47f0fd14a843f376e2178b267fcc97d735f8be4f1d6
4
- data.tar.gz: 03caef2a674828781c28e2f7ee7887f2e751e2a8e72da39afd4edb189a6b564f
3
+ metadata.gz: cd47d422f2107d9768a64002fd8cf3505606d508342d0415a3f336312f439d6d
4
+ data.tar.gz: a5f96d052d0905fc4a2eb2049a81124c6f01790897de453ac7ce40a1652ba08e
5
5
  SHA512:
6
- metadata.gz: 4f5ce77b84c2dc57d100e893386a400ae0f716b1e3d96de1d446a5e5cd6b485cea86d317b5e04b95f164fe389a543c655b60dbab14b4c622f8389554b566cc1b
7
- data.tar.gz: b5eb81a88537b105707cc7cf2b292b1d6afa08395d69f267df30161b8fcc9c699d32cfa725cc21cd70e202dc80457e29f97c02be080269e39ef1f9cfc9c770ed
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.5
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-08-19 00:00:00.000000000 Z
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