How to encrypt a field with md5 in an application using react-native?

0

Good, I am currently developing an app and I have the need to encrypt the pass entered by the user with md5 and then send it to an api stored on a server, the app is doing it with react-native but when searching on google I only find libraries to export it to a php and I'm not sure if I can use PHP.js that has that function, with react-native (or if it's even compatible)

    
asked by Alberto José 26.10.2017 в 19:18
source

1 answer

0

According to the npm page you can use the following library in this way

npm install react-native-md5 --did you have to run it on your operating system console

import EventEmitter from "react-native-md5"; this is to import the library into your project

This would be an example how to use it

import md5 from "react-native-md5";

componentWillMount() {

    let hex_md5v = md5.hex_md5( Date.now() +"" );
    console.log(">>>>hex_md5:", hex_md5v);

    let b64_md5v = md5.b64_md5( Date.now() +"" );
    console.log(">>>>b64_md5:", b64_md5v);

    let str_md5v = md5.str_md5( Date.now() +"" );
    console.log(">>>>str_md5:", str_md5v);

    let hex_hmac_md5v = md5.hex_hmac_md5("my_key", Date.now() +"" );
    console.log(">>>>hex_hmac_md5:", hex_hmac_md5v);

    let b64_hmac_md5v = md5.b64_hmac_md5("my_key", Date.now() +"" );
    console.log(">>>>b64_hmac_md5:", b64_hmac_md5v);

    let str_hmac_md5v = md5.str_hmac_md5("my_key", Date.now() +"" );
    console.log(">>>>str_hmac_md5:", str_hmac_md5v);

}

the link where you can see it is link

    
answered by 27.10.2017 / 16:48
source