-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
60 lines (48 loc) · 2.09 KB
/
main.go
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
package main
import (
"bufio"
"fmt"
"os"
"strings"
"github.com/joho/godotenv"
"golang.design/x/clipboard"
)
func main() {
// Load environment variables from the .env file
if err := godotenv.Load(); err != nil {
panic(fmt.Sprintf("Error loading .env file: %v\n", err))
}
// Get keys from env file
secretKey := os.Getenv("ENC_SECRET_KEY_HEX")
iv := os.Getenv("ENC_IV_HEX")
INSTANCE_NAME := os.Getenv("INSTANCE_NAME")
fmt.Println("\n----------------------------------------------------------------")
fmt.Println("\n-------------------------- Beta LMS --------------------------")
fmt.Println("\n----------------------------------------------------------------")
fmt.Println("\n---------------- The Only Secure LMS You Need ----------------")
fmt.Println("\n----------------------------------------------------------------")
fmt.Println("\n--------- Welcome to Beta LMS Video Processor! (v1) ----------")
fmt.Println("\n----------------------------------------------------------------")
fmt.Printf("\nWelcome to Beta LMS Instance: %v\n\n", INSTANCE_NAME)
// Get inputs from user
scanner := bufio.NewScanner(os.Stdin)
fmt.Print("Enter the path of the video file: ")
scanner.Scan()
filePath := strings.ReplaceAll(scanner.Text(), "\"", "")
fmt.Print("\nEnter the link of the YouTube video: ")
scanner.Scan()
youtubeLink := scanner.Text()
encryptedPath := GetEncryptedFilePath(filePath, youtubeLink)
if err := EncryptFile(filePath, encryptedPath, secretKey, iv); err != nil {
panic(fmt.Sprintf("Error: %v\n", err))
}
fmt.Println("\nFile encrypted successfully.")
fmt.Printf("\nEncrypted file path: %s\n", encryptedPath)
fmt.Printf("\nEncrypted file name (already copied to clipboard): %s\n", encryptedPath[strings.LastIndex(encryptedPath, "\\")+1:strings.LastIndex(encryptedPath, ".")])
if err := clipboard.Init(); err != nil {
panic(fmt.Sprintf("Error initializing clipboard: %v\n", err))
}
clipboard.Write(clipboard.FmtText, []byte(encryptedPath[strings.LastIndex(encryptedPath, "\\")+1:strings.LastIndex(encryptedPath, ".")]))
fmt.Println("\nPress Enter to exit.")
scanner.Scan()
}