-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapi.R
More file actions
66 lines (51 loc) · 1.47 KB
/
api.R
File metadata and controls
66 lines (51 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
library(decryptr)
library(base64enc)
model_rfb <- load_model("rfb")
model_rsc <- load_model("rsc")
model_cadesp <- load_model("cadesp")
model_nfesp <- load_model("nfesp")
keys <- yaml::read_yaml("keys.yaml")
#* @get /
root <- function() {
"hello world"
}
#* @post /rfb
rfb <- function(img, key){
key <- openssl::sha256(key)
if(!key %in% keys | is.null(key) | is.na(key)) {
stop("Not authorized. Get an api key from decryptr.com.br")
}
img_decoded <- base64enc::base64decode(img)
message(Sys.time(), ": rfb")
decrypt(img_decoded, model_rfb)
}
#* @post /rsc
rsc <- function(img, key){
key <- openssl::sha256(key)
if(!key %in% keys | is.null(key) | is.na(key)) {
stop("Not authorized. Get an api key from decryptr.com.br")
}
img_decoded <- base64enc::base64decode(img)
message(Sys.time(), ": rsc")
decrypt(img_decoded, model_rsc)
}
#* @post /cadesp
cadesp <- function(img, key){
key <- openssl::sha256(key)
if(!key %in% keys | is.null(key) | is.na(key)) {
stop("Not authorized. Get an api key from decryptr.com.br")
}
img_decoded <- base64enc::base64decode(img)
message(Sys.time(), ": cadesp")
decrypt(img_decoded, model_cadesp)
}
#* @post /nfesp
nfesp <- function(img, key){
key <- openssl::sha256(key)
if(!key %in% keys | is.null(key) | is.na(key)) {
stop("Not authorized. Get an api key from decryptr.com.br")
}
img_decoded <- base64enc::base64decode(img)
message(Sys.time(), ": nfesp")
decrypt(img_decoded, model_nfesp)
}