This repository has been archived by the owner on Feb 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
90 lines (77 loc) · 2.38 KB
/
App.js
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
import React, { Component } from 'react';
import {
Button,
AsyncStorage,
WebView,
//AppRegistry,
View,
ScrollView,
//ListView,
StyleSheet,
Text,
TouchableHighlight,
TouchableOpacity,
TextInput,
} from 'react-native';
import { StackNavigator } from 'react-navigation'; // 1.5.9
import { Row, Column as Col, Grid} from 'react-native-responsive-grid'
//import 'crypto-js'
var CryptoJS = require("crypto-js");
var ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123');
//ciphertext.ciphertext
// // Encrypt
// Decrypt
var bytes = CryptoJS.AES.decrypt(ciphertext.toString(), 'secret key 123');
var plaintext = bytes.toString(CryptoJS.enc.Utf8);
console.log(plaintext);
debugger;
var RSAKey = require('react-native-rsa');
import {Login} from './src/login'
import {l, tokenAndFetch} from './src/utils'
import {Dialog} from './src/dialog'
import{DialogsList} from './src/dialogs_list'
const AESRecognizingFirstSymbols = "encryptedAAA";
const AESRFS = AESRecognizingFirstSymbols;
// // Encrypt
// var ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123');
// ciphertext.ciphertext
// // Decrypt
// var bytes = CryptoJS.AES.decrypt(ciphertext.toString(), 'secret key 123');
// var plaintext = bytes.toString(CryptoJS.enc.Utf8);
//console.log(plaintext);
l("react-native-rsa")
const bits = 1024;
const exponent = '10001'; // must be a string. This is hex string. decimal = 65537
var rsa = new RSAKey();
rsa.generate(bits, exponent);
var publicKey = rsa.getPublicString(); // return json encoded string
var privateKey = rsa.getPrivateString(); // return json encoded string
var rsa = new RSAKey();
rsa.setPublicString(publicKey);
var originText = 'sample String Value';
var encrypted = rsa.encrypt(originText);
rsa.setPrivateString(privateKey);
var decrypted = rsa.decrypt(encrypted); // decrypted == originText
// l(decrypted)
// tokenAndFetch('https://api.vk.com/method/storage.set?v=5.52&access_token=[access_token]'+
// 'global=1&&key=rsaopen&&value='+encodeURI(publicKey), null)//+'user_id
// .then(json=>
// console.info)
// .catch(e => {console.error("storage.set: " + e);debugger;});
//AppRegistry.registerComponent('DialogsList',()=>DialogsList);
export default StackNavigator(
{
_DialogsList: {
screen: DialogsList,
},
_Dialog: {
screen: Dialog,
},
_Login: {
screen: Login,
},
},
{
initialRouteName: '_DialogsList',
}
);