Quellcode durchsuchen

added stuff for encryption

remeber to change the IP addrs
Orlando04 vor 2 Jahren
Ursprung
Commit
7b528f101d

+ 6
- 0
MocionesIUPI/package-lock.json Datei anzeigen

@@ -10,6 +10,7 @@
10 10
       "dependencies": {
11 11
         "@apollo/client": "^3.7.2",
12 12
         "@expo/webpack-config": "^0.17.2",
13
+        "crypto-js": "^4.1.1",
13 14
         "deprecated-react-native-prop-types": "^2.2.0",
14 15
         "expo": "~47.0.6",
15 16
         "expo-status-bar": "~1.4.2",
@@ -8362,6 +8363,11 @@
8362 8363
         "node": "*"
8363 8364
       }
8364 8365
     },
8366
+    "node_modules/crypto-js": {
8367
+      "version": "4.1.1",
8368
+      "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz",
8369
+      "integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw=="
8370
+    },
8365 8371
     "node_modules/crypto-random-string": {
8366 8372
       "version": "2.0.0",
8367 8373
       "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz",

+ 1
- 0
MocionesIUPI/package.json Datei anzeigen

@@ -11,6 +11,7 @@
11 11
   "dependencies": {
12 12
     "@apollo/client": "^3.7.2",
13 13
     "@expo/webpack-config": "^0.17.2",
14
+    "crypto-js": "^4.1.1",
14 15
     "deprecated-react-native-prop-types": "^2.2.0",
15 16
     "expo": "~47.0.6",
16 17
     "expo-status-bar": "~1.4.2",

+ 13
- 9
MocionesIUPI/screens/MocionScreen.js Datei anzeigen

@@ -1,5 +1,7 @@
1 1
 import React, { useEffect, useState } from 'react';
2 2
 import { ActivityIndicator, Button, FlatList, Text, View } from 'react-native';
3
+import { CryptoJS } from "crypto-js/aes";
4
+import { globalStyles } from '../styles/global';
3 5
 
4 6
 export default App = ({ navigation }) => {
5 7
   const [mocion, setMocion] = useState(null);
@@ -10,7 +12,7 @@ export default App = ({ navigation }) => {
10 12
   // this connects us to the API and fetches the json file with the mociones
11 13
   const getMociones = async () => {
12 14
      try {
13
-      const response = await fetch(`http://10.0.0.65:5000/send?PIN=${navigation.state.params.Pin}`); // connection to the website 
15
+      const response = await fetch(`http://10.190.1.140:5000/send?PIN=${navigation.state.params.Pin}`); // connection to the website 
14 16
       const json = await response.json();
15 17
       setMocion(json.Mocion);
16 18
       setDescription(json.Description);
@@ -31,10 +33,17 @@ export default App = ({ navigation }) => {
31 33
 
32 34
     //sending to the API
33 35
     const PIN = pin;
34
-    const Token = 'abc123';
36
+    const message = 'abc123';
35 37
     const votos = value;
36 38
 
37
-    const url = `http://10.190.1.140:5000/vote?PIN=${PIN}&Token=${Token}&votos=${votos}`;
39
+     // this is for encrypting the message
40
+    var CryptoJS = require('crypto-js');
41
+    const privKey = "MOCIONES_IUPI";
42
+
43
+    const Token = CryptoJS.AES.encrypt(message,privKey);
44
+    const privKey_encrypt = CryptoJS.AES.encrypt(privKey, privKey); 
45
+
46
+    const url = `http://10.190.1.140:5000/vote?PIN=${PIN}&Token=${Token}&votos=${votos}&privKey_encrypt=${privKey_encrypt}`;
38 47
 
39 48
     //connecting to API
40 49
     fetch(url);
@@ -49,16 +58,11 @@ export default App = ({ navigation }) => {
49 58
       <Text>{mocion}</Text>
50 59
       <Text>{description}</Text>
51 60
       
52
-      {/* container for the look of the buttons */}
53
-      <View>
54
-
55
-      <Button title='A favor' onPress={() => sendVotes('A Favor')} />
61
+      <Button title='A favor' onPress={() => sendVotes('A Favor')}/>
56 62
       <Button title='En Contra'onPress={() => sendVotes('En Contra')} />
57 63
       <Button title='Abstenido/a' onPress={() => sendVotes('Abstenido/a')} />
58 64
 
59 65
 
60
-      </View>
61
-
62 66
     </View>
63 67
   );
64 68
 };

+ 1
- 1
MocionesIUPI/screens/PincodeScreen.js Datei anzeigen

@@ -12,7 +12,7 @@ export default class App extends React.Component {
12 12
     // this checks the pin the user inputs to see if there is a mocion with that pin
13 13
     getPin = async (code) => {
14 14
        try {
15
-        const response = await fetch(`http://10.0.0.65:5000/send?PIN=${code}`); // connection to the website 
15
+        const response = await fetch(`http://10.190.1.140:5000/send?PIN=${code}`); // connection to the website 
16 16
         const json = await response.json();
17 17
         console.log(json);
18 18