Change plaintext format

Brightcells 7 years ago
parent
commit
14faa83d54
1 changed files with 7 additions and 8 deletions
  1. 7 8
      api/encrypt_views.py

+ 7 - 8
api/encrypt_views.py

@@ -17,8 +17,8 @@ from utils.algorithm.rsalg import rsa_decrypt, rsa_encrypt
17 17
 CIPHER_ALGORITHM = ('B64', )
18 18
 
19 19
 CIPHER_PREFIX = {
20
-    'B64': 'alg1',
21
-    'RSA': 'alg2',
20
+    'B64': '1',
21
+    'RSA': '2',
22 22
 }
23 23
 
24 24
 
@@ -53,18 +53,17 @@ def decrypt(request):
53 53
     else:
54 54
         plaintext = ciphertext
55 55
 
56
-    infos = json.loads(plaintext)
57
-
58
-    Brand = infos.get('Brand', '')
59
-    Model = infos.get('Model', '')
56
+    # brand_id#model_id#distributor_id#sn#time
57
+    # AAAA#AAAAAA#AAAAA#AAAAAAAAAAAAAA#180224
58
+    brand_id, model_id, distributor_id, sn, time = plaintext.split('#')
60 59
 
61 60
     try:
62
-        logo_url = BrandInfo.objects.get(brand_name=Brand).brand_logo_url
61
+        logo_url = BrandInfo.objects.get(brand_id=brand_id).brand_logo_url
63 62
     except BrandInfo.DoesNotExist:
64 63
         logo_url = ''
65 64
 
66 65
     try:
67
-        model_imgs = ModelInfo.objects.get(model_name=Model).images
66
+        model_imgs = ModelInfo.objects.get(model_id=model_id).images
68 67
     except ModelInfo.DoesNotExist:
69 68
         model_imgs = []
70 69