-
Notifications
You must be signed in to change notification settings - Fork 7
/
.Rhistory
86 lines (86 loc) · 2.44 KB
/
.Rhistory
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
shiny::runApp()
DB_NAME <- "data.sqlite"
TBL_USER_DATA <- "users"
DB_test_connect <- function(){
db <- dbConnect(RSQLite::SQLite(), DB_NAME)
print("#######################")
print("- Connected to Database")
# If a user data table doesn't already exist, create one
if(!(TBL_USER_DATA %in% dbListTables(db))){
print("- Warning: No 'users' table found. Creating table...")
df <- data.frame(ID = as.numeric(character()),
USER = character(),
HASH = character(),
stringsAsFactors = FALSE)
dbWriteTable(db, TBL_USER_DATA, df)
}
print("- Table exists.")
print("#######################")
dbDisconnect(db)
unlink(DB_NAME)
}
DB_test_connect()
db <- dbConnect(RSQLite::SQLite(), DB_NAME)
if(!(TBL_USER_DATA %in% dbListTables(db))){
print("- Warning: No 'users' table found. Creating table...")
df <- data.frame(ID = as.numeric(character()),
USER = character(),
HASH = character(),
stringsAsFactors = FALSE)
dbWriteTable(db, TBL_USER_DATA, df)
}
dbDisconnect(db)
db <- dbConnect(RSQLite::SQLite(), DB_NAME)
DB_NAME <- "data.sqlite"
TBL_USER_DATA <- "users"
db <- dbConnect(RSQLite::SQLite(), DB_NAME)
dbDisconnect(db)
DB_NAME <- "data.sqlite"
TBL_USER_DATA <- "users"
DB_test_connect <- function(){
db <- dbConnect(RSQLite::SQLite(), DB_NAME)
print("#######################")
print("- Connected to Database")
# If a user data table doesn't already exist, create one
if(!(TBL_USER_DATA %in% dbListTables(db))){
print("- Warning: No 'users' table found. Creating table...")
df <- data.frame(ID = as.numeric(character()),
USER = character(),
HASH = character(),
stringsAsFactors = FALSE)
dbWriteTable(db, TBL_USER_DATA, df)
}
print("- Table exists.")
print("#######################")
dbDisconnect(db)
}
DB_test_connect()
runApp()
library(bcrypt)
runApp()
runApp()
db <- dbConnect(RSQLite::SQLite(), DB_NAME)
DB_NAME <- "data.sqlite"
TBL_USER_DATA <- "users"
db <- dbConnect(RSQLite::SQLite(), DB_NAME)
users_data <- dbReadTable(db, TBL_USER_DATA)
View(users_data)
sha256(abc)
sha256("abc")
identical(sha256("abc"), users_data$HASH[1])
identical(sha256("abc", key = users_data$HASH[1]), users_data$HASH[1])
hash <- users_data[users_data$USER=="abc", "HASH"]
hash <- users_data[users_data$USER=="abc", "HASH"]
hash
identical(hash, sha256("abc"))
sha256("abc")
hash
sha256("abc") == hash
runApp()
db <- dbConnect(RSQLite::SQLite(), DB_NAME)
DB_NAME <- "data.sqlite"
TBL_USER_DATA <- "users"
db <- dbConnect(RSQLite::SQLite(), DB_NAME)
users_data <- dbReadTable(db, TBL_USER_DATA)
dbDisconnect(db)
dbDisconnect(db)