Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
¿Cómo puedo usar esta biblioteca React Native PGP?

Quiero hacer una aplicación que solo genere un par de claves PGP y lo muestre en aquellos con useState pero no entendí nada en la documentación https://github.com/jerson/react-native-fast-openpgp#readme :/ alguien me puede ayudar ?

Solo generar, cifrar/descifrar sería un proyecto para más adelante, soy nuevo en React Native y no quiero complicarlo demasiado.

 import { StatusBar } from 'expo-status-bar'; import { useState } from 'react'; import { StyleSheet, Text, View, Button } from 'react-native'; export default function App() { const [MyPublicKey,setMyPublicKey] = useState('No key yet'); const [MyPrivateKey,setMyPrivateKey] = useState('No key yet'); const [ButtonText,setButtonText] = useState('Generate Keypair'); const GenerateKeypair = ()=>{ // This is an Example, Here Should be the Function from the Library setMyPublicKey('-----BEGIN PGP PUBLIC KEY BLOCK-----') setMyPrivateKey('-----BEGIN PGP Private KEY BLOCK-----') setButtonText('renew') } return ( <View style={styles.container}> <Text>{MyPublicKey} </Text> <Text> {MyPrivateKey} </Text> <Button onPress={GenerateKeypair} title={ButtonText}/> <StatusBar style="auto" /> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'space-evenly', }, });

Usé la biblioteca openpgp para la reacción normal, pero con la reacción nativa no funciona, todo lo que tenía que hacer era esto:

 const [MyPrivateKey,setMyPrivateKey] = useState(''); const [MyPublicKey,setMyPublicKey] = useState(''); const [MyRevocation,setMyRevocation] = useState(''); const GenerateKeypair = async () => { const { privateKey, publicKey, revocationCertificate } = await generateKey({ type: 'ecc', // Type of the key, defaults to ECC curve: 'curve25519', // ECC curve name, defaults to curve25519 userIDs: [{ name: 'Jon Smith', email: 'jon@example.com' }], // you can pass multiple user IDs passphrase: 'super long and hard to guess secret', // protects the private key format: 'armored' // output key format, defaults to 'armored' (other options: 'binary' or 'object') }); setMyPrivateKey(privateKey); // '-----BEGIN PGP PRIVATE KEY BLOCK ... ' setMyPublicKey(publicKey); // '-----BEGIN PGP PUBLIC KEY BLOCK ... ' setMyRevocation(revocationCertificate); // '-----BEGIN PGP PUBLIC KEY BLOCK ... ' }
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!