Skip to content

Commit 17d0fcc

Browse files
committed
initial release
0 parents  commit 17d0fcc

File tree

8 files changed

+6502
-0
lines changed

8 files changed

+6502
-0
lines changed

LICENSE

+674
Large diffs are not rendered by default.

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# BCC Crypt
2+
> A RedM Cryptography and Hashing library for lua developers
3+
4+
## Features
5+
- UUID v4 Generation
6+
- Base64 Encryption/Decryption
7+
- RC4 Encryption/Decryption
8+
- SHA Hashing
9+
- SHA-1
10+
- SHA-2
11+
- SHA-3
12+
- BLAKE2
13+
- BLAKE3
14+
15+
## How to install
16+
* Download this repo
17+
* Copy and paste `bcc-crypt` folder to `resources/bcc-crypt`
18+
* Add `ensure bcc-crypt` to your `server.cfg` file
19+
* Now you are ready to get coding!
20+
21+
## Documentation
22+
[OFFICIAL BCC CRYPT DOCS](https://github.com/BryceCanyonCounty/bcc-crypt/wiki)
23+
24+
## Disclaimers and Credits
25+
> I appreciate the hard work of the following developers, without all the different codebases, this script would not be possible.
26+
27+
_All script credits will be listed at the top of each service file_
28+
29+
## Need More Support?
30+
- [Vorp Disord](https://discord.gg/DHGVAbCj7N)

fxmanifest.lua

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
fx_version 'adamant'
2+
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
3+
4+
game 'rdr3'
5+
lua54 'yes'
6+
7+
author 'Bytesizd'
8+
description 'A script with various bug fixes for vehicles.'
9+
10+
server_script {
11+
'server/api.lua',
12+
'services/*.lua'
13+
}
14+
15+
shared_script {
16+
'config.lua'
17+
}
18+
19+
version '1.0.0'

server/api.lua

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
exports('install', function()
2+
print("INSTALLED!")
3+
return {
4+
uuid4 = UUID4,
5+
sha = SHA2,
6+
rc4 = {
7+
decrypt = RC4.decrypt,
8+
encrypt = RC4.encrypt
9+
},
10+
base64 = {
11+
decrypt = Base64.decrypt,
12+
encrypt = Base64.encrypt
13+
}
14+
}
15+
end)
16+

services/base64.lua

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
-- From http://lua-users.org/wiki/BaseSixtyFour
2+
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
3+
4+
local function encrypt(data)
5+
return ((data:gsub('.', function(x)
6+
local r,b='',x:byte()
7+
for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
8+
return r;
9+
end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
10+
if (#x < 6) then return '' end
11+
local c=0
12+
for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
13+
return b:sub(c+1,c+1)
14+
end)..({ '', '==', '=' })[#data%3+1])
15+
end
16+
17+
18+
local function decrypt(data)
19+
data = string.gsub(data, '[^'..b..'=]', '')
20+
return (data:gsub('.', function(x)
21+
if (x == '=') then return '' end
22+
local r,f='',(b:find(x)-1)
23+
for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
24+
return r;
25+
end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
26+
if (#x ~= 8) then return '' end
27+
local c=0
28+
for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
29+
return string.char(c)
30+
end))
31+
end
32+
33+
Base64 = {
34+
encrypt = encrypt,
35+
decrypt = decrypt
36+
}

services/rc4.lua

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
-- https://en.wikipedia.org/wiki/RC4
2+
3+
local function swap( i, j )
4+
return j, i
5+
end
6+
7+
local function rc4(key, input)
8+
local S = {}
9+
for i = 0, 255 do
10+
S[ i ] = i
11+
end
12+
13+
local j = 0
14+
for i = 0, 255 do
15+
j = ( j + S[ i ] + key:byte( i % #key + 1 ) ) % 256
16+
S[ i ], S[ j ] = swap( S[ i ], S[ j ] )
17+
end
18+
19+
local out = ""
20+
21+
local i, j = 0, 0
22+
for k = 1, #input do
23+
i = ( i + 1 ) % 256
24+
j = ( j + S[ i ] ) % 256
25+
S[ i ], S[ j ] = swap( S[ i ], S[ j ] )
26+
27+
local K = S[ ( S[ i ] + S[ j ] ) % 256 ]
28+
29+
out = out .. string.char( input:byte( i ) ~ K )
30+
end
31+
32+
return out
33+
end
34+
35+
36+
RC4 = {
37+
encrypt = rc4,
38+
decrypt = rc4
39+
}

0 commit comments

Comments
 (0)