-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
17 additions
and
145 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local M = {} | ||
|
||
M.hash = function() return require("fittencode.cc.projects.hash") end | ||
|
||
return M |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package.cpath = package.cpath .. ';' .. require('cpath') | ||
|
||
local _, CC = pcall(require, 'hash') | ||
if not _ then | ||
return | ||
end | ||
|
||
return CC |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
This file was deleted.
Oops, something went wrong.
14 changes: 4 additions & 10 deletions
14
lua/fittencode/hash/cc/init.lua → lua/fittencode/hash/hash.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,23 @@ | ||
package.cpath = package.cpath .. ';' .. require('cpath') | ||
|
||
local _, C = pcall(require, 'hash') | ||
if not _ then | ||
return | ||
end | ||
|
||
local CC = require("fittencode.cc").hash() | ||
local Fn = require('fittencode.fn') | ||
|
||
local M = {} | ||
|
||
function M.is_supported(method) | ||
return C[string.lower(method)] | ||
return CC[string.lower(method)] | ||
end | ||
|
||
function M.hash(method, plaintext, on_success, on_error) | ||
if not M.is_supported(method) then | ||
Fn.schedule_call(on_error) | ||
return | ||
end | ||
local _, ciphertext = pcall(C[string.lower(method)], plaintext) | ||
local _, ciphertext = pcall(CC[string.lower(method)], plaintext) | ||
if _ then | ||
Fn.schedule_call(on_success, ciphertext) | ||
else | ||
Fn.schedule_call(on_error) | ||
end | ||
end | ||
|
||
return M | ||
return M |
Empty file.