app/index.js
//Create directory, files, and AES values
Create directory, files, and AES values
Create directory files and AES values
init(){
        const dirs = RNFetchBlob.fs.dirs;
        paths = this.getPaths();
        RNFetchBlob.fs.mkdir(paths.dirPath)
        .catch((err) => {});
        RNFetchBlob.fs.exists(paths.cardsPath)
        .then((exist) => {
            if (exist === false){
                RNFetchBlob.fs.createFile(
                    paths.cardsPath,
                    '',
                    'utf8'
                )
                .catch((err) => {});
            }
        });
        RNFetchBlob.fs.exists(paths.messagesPath)
        .then((exist) => {
            if (exist === false){
                RNFetchBlob.fs.createFile(
                    paths.messagesPath,
                    '',
                    'utf8'
                )
                .catch((err) => {});
            }
        });
        SInfo.getItem('key', {})
        .then((value) => {
            if (value == null){
                for(var key = ''; key.length < 16;)
                    key += Math.random().toString(36).substr(2, 1)
                SInfo.setItem('key', key, {});
                this.setState({key: key});
            }
            else
                this.setState({key: value});
        });
        SInfo.getItem('iv', {})
        .then((value) => {
            if (value == null){
                for(var iv = ''; iv.length < 16;)
                    iv += Math.random().toString(36).substr(2, 1)
                SInfo.setItem('iv', iv, {});
                this.setState({iv: iv});
            }
            else
                this.setState({iv: value});
        });
    }
init ( ) { const dirs = RNFetchBlob . fs . dirs ; paths = this . getPaths ( ) ; RNFetchBlob . fs . mkdir ( paths . dirPath ) . catch ( ( err ) => { } ) ; RNFetchBlob . fs . exists ( paths . cardsPath ) . then ( ( exist ) => { if ( exist === false ) { RNFetchBlob . fs . createFile ( paths . cardsPath , '' , 'utf8' ) . catch ( ( err ) => { } ) ; } } ) ; RNFetchBlob . fs . exists ( paths . messagesPath ) . then ( ( exist ) => { if ( exist === false ) { RNFetchBlob . fs . createFile ( paths . messagesPath , '' , 'utf8' ) . catch ( ( err ) => { } ) ; } } ) ; SInfo . getItem ( 'key' , { } ) . then ( ( value ) => { if ( value == null ) { for ( var key = '' ; key . length < 16 ; ) key += Math . random ( ) . toString ( 36 ) . substr ( 2 , 1 ) SInfo . setItem ( 'key' , key , { } ) ; this . setState ( { key : key } ) ; } else this . setState ( { key : value } ) ; } ) ; SInfo . getItem ( 'iv' , { } ) . then ( ( value ) => { if ( value == null ) { for ( var iv = '' ; iv . length < 16 ; ) iv += Math . random ( ) . toString ( 36 ) . substr ( 2 , 1 ) SInfo . setItem ( 'iv' , iv , { } ) ; this . setState ( { iv : iv } ) ; } else this . setState ( { iv : value } ) ; } ) ; }
Create directory, files, and AES values
Create directory files and AES values