-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyDialoge.gd
257 lines (155 loc) · 5.14 KB
/
myDialoge.gd
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
extends Control
onready var OpenButton = $VBoxContainer/OpenButton
onready var MSG_Text = $InfoLabelMSG/Info
onready var SpinKasten: SpinBox = $DetailsDialog/HSlider/SpinBox
onready var Regler: HSlider = $DetailsDialog/HSlider
onready var DetailsMSG: WindowDialog = $DetailsDialog
var aes = AESContext.new()
var my_password:String
const Divider16: int = 16
const Divider32: int = 32
# Called when the node enters the scene tree for the first time.
func _ready():
$VBoxContainer/OpenButton.grab_focus()
# Bestimmte Datei Erweiterung (.txt) voreinstellen.
$OpenDialog.add_filter("*.txt")
$SaveDialog.add_filter("*.txt")
pass
func Date_Encrypt():
var aes_two = AESContext.new()
var MyKey = $KeyFieldLine.text # Key must be either 16 or 32 bytes.
var MyText = $InputText.text # Info/Text/Message
# Daten (MyText) mit MyKey (Password) verschluesseln
print(MyKey)
print(MyText)
aes_two.start(AESContext.MODE_ECB_ENCRYPT, MyKey.to_utf8())
var myEncrypted = aes_two.update(MyText.to_utf8())
aes_two.finish()
print(myEncrypted)
pass
func _on_OpenButton_pressed():
MSG_Text.text = "Pressed 'Open'"
$OpenDialog.popup()
pass # Replace with function body.
func _on_SaveButton_pressed():
MSG_Text.text = "Pressed 'Save'"
$SaveDialog.popup()
pass # Replace with function body.
func _on_ResetButton_pressed():
MSG_Text.text = "'Reset': Clear"
# # # Alles zurueck setzen!
# Textfeld leeren
$InputText.text = ""
# Passwordfeld leeren
$KeyFieldLine.text = ""
# Das Feld verdecken als "*" anzeigen
$KeyFieldLine.secret = true
# Schalte umsetzen
$CheckButton.pressed = false
# Textfeld (Ausgabefeld) leeren
$Output.text =""
# Regler auf Standart zurück setzen
Regler.value = Regler.min_value
pass # Replace with function body.
func _on_ExitButton_pressed():
MSG_Text.text = "Pressed 'Exit'"
# Exit Program
get_tree().quit()
func _on_OpenDialog_file_selected(path):
var f = File.new()
f.open(path,1)
$InputText.text = f.get_as_text()
f.close()
func _on_SaveDialog_file_selected(path):
var f = File.new()
f.open(path,2)
f.store_string($InputText.text)
f.close()
func _on_EnCryptButton_pressed():
if $InputText.text == "" and $KeyFieldLine.text == "":
$MsgDialog.dialog_text = "Keine Nachricht und Password eingegeben - Bitte beide ausfuellen"
$MsgDialog.popup()
return
if $InputText.text == "":
$MsgDialog.dialog_text = "Nachricht Feld - Bitte ausfuellen"
$MsgDialog.popup()
return
if $KeyFieldLine.text == "":
$MsgDialog.dialog_text = "Kein Password eingegeben. Bitte eingeben."
$MsgDialog.popup()
return
Date_Encrypt()
pass # Replace with function body.
func _on_CheckButton_pressed():
# $MsgDialog.dialog_text = "Pressed"
# $MsgDialog.popup()
# Password - Feld nicht anzeigen, stattdessen als "*" anzeigen
if $CheckButton.pressed == false:
$KeyFieldLine.secret = true
return
# Password - Feld anzeigen
if $CheckButton.pressed == true:
$KeyFieldLine.secret = false
return
pass # Replace with function body.
func _on_CounterButton_pressed():
var Length_Counter_Text:int
var Length_Counter_Pass_Key:int
var Lenght_Char:String
# Zeichenlaenge fuer Inhalt
Lenght_Char = $InputText.text
Length_Counter_Text = Lenght_Char.length()
# Zeichenlaenge fuer Passwort
Lenght_Char = $KeyFieldLine.text
Length_Counter_Pass_Key = Lenght_Char.length()
# Zeichenlaenge für Inhalt und Passwort auf dem Dialogsfeld
# anzeigen:
$MsgDialog.dialog_text = "TextLaenge: " + str(Length_Counter_Text) \
+ "\n" + "PasswordLaenge: " + str(Length_Counter_Pass_Key) + "\n"
$MsgDialog.popup()
pass # Replace with function body.
# Hinweis:
#
# Date: 24. November 2022
#
# Die Funktion "generate_char" wurde unterstützend ergänzt von:
# einem User "whiteshampoo" aus dem Discord Kanal "Deutsche Godot Community"
#
# Link zu den Discord-Kanal:
#
# "https://discord.com/channels/553242711109533729/584063445150728215"
#
const ASCII_START: int = ord("!")
const ASCII_END: int = ord("~")
func generate_char (var return_length:int) -> String:
# von "!" bis "~"
# 21h (33d) - 7Eh (126d) Ascii - Code (UTF8)
if return_length <= 0:
printerr("generate_char was called with return_length %d" % return_length)
return ""
var output:String
var random: RandomNumberGenerator = RandomNumberGenerator.new()
random.randomize()
for __ in range(return_length):
output += char(random.randi_range(ASCII_START, ASCII_END))
return output
func _on_AutoFillButton_pressed():
$KeyFieldLine.text = generate_char(16)
$InputText.text = generate_char(Regler.value)
pass # Replace with function body.
func _on_DetailsButton_pressed():
DetailsMSG.popup()
pass # Replace with function body.
func _on_HSlider_value_changed(value):
SpinKasten.value = Regler.value
pass # Replace with function body.
func _on_SpinBox_value_changed(value):
Regler.value = SpinKasten.value
pass # Replace with function body.
func _on_Button_pressed():
DetailsMSG.hide()
pass # Replace with function body.
func _on_ButtonCallDialog_pressed():
# $"/root/MyButton/TMeldung".popup()
$TMeldung.popup()
pass # Replace with function body.