Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
Version 1.2-1
Browse files Browse the repository at this point in the history
  • Loading branch information
ttwizz committed Apr 15, 2024
1 parent 40573e1 commit 45fa441
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
40 changes: 20 additions & 20 deletions pixcrypt-1.1-1.rockspec → pixcrypt-1.2-1.rockspec
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package = "pixcrypt"
version = "1.1-1"
source = {
url = "git+https://github.com/ttwizz/pixcrypt.git"
}
description = {
summary = "Key-based Encryption & Decryption Library",
detailed = "This module allows you to encrypt and decrypt the necessary data using a key.",
homepage = "https://github.com/ttwizz/pixcrypt",
license = "MIT"
}
dependencies = {
"lua >= 5.1"
}
build = {
type = "builtin",
modules = {
pixcrypt = "src/pixcrypt.lua"
}
}
package = "pixcrypt"
version = "1.2-1"
source = {
url = "git+https://github.com/ttwizz/pixcrypt.git"
}
description = {
summary = "Key-based Encryption & Decryption Library",
detailed = "This module allows you to encrypt and decrypt the necessary data using a key.",
homepage = "https://github.com/ttwizz/pixcrypt",
license = "MIT"
}
dependencies = {
"lua >= 5.1"
}
build = {
type = "builtin",
modules = {
pixcrypt = "src/pixcrypt.lua"
}
}
11 changes: 8 additions & 3 deletions src/pixcrypt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,43 @@
]]


local pixcrypt = {}
local pixcrypt = { Secret = 2773480762 }


function pixcrypt:Encrypt(Key, String)
assert(type(Key) == "string", "Argument 1 (Key) must be a string")
assert(type(String) == "string", "Argument 2 (String) must be a string")

local Summand = #Key + math.pi * 4.3579
local Index = 1
local Result = ""

for Character in string.gmatch(Key, ".") do
Summand = Summand + string.byte(Character) / 1.8602
end
for Character in string.gmatch(String, ".") do
Result = Result .. string.byte(Character) / 2.1748 + Summand .. "xip"
Result = Result .. string.byte(Character) / 2.1748 + Summand * (pixcrypt.Secret / Index) .. "xip"
Index = Index + 1
end

return string.gsub(string.reverse(string.sub(Result, 1, -4)), "%.", "$")
end


function pixcrypt:Decrypt(Key, String)
assert(type(Key) == "string", "Argument 1 (Key) must be a string")
assert(type(String) == "string", "Argument 2 (String) must be a string")

local Summand = #Key + math.pi * 4.3579
local Index = 1
local Result = ""

for Character in string.gmatch(Key, ".") do
Summand = Summand + string.byte(Character) / 1.8602
end
for Character in string.gmatch(string.gsub(string.reverse(String), "%$", "."), "([^xip]+)") do
Result = Result .. string.char(math.floor((Character - Summand) * 2.1748 + 0.5))
Result = Result .. string.char(math.floor((Character - Summand * (pixcrypt.Secret / Index)) * 2.1748 + 0.5))
Index = Index + 1
end

return Result
Expand Down

0 comments on commit 45fa441

Please sign in to comment.