Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Get SHA-1 key in React Native cli?

In React Native when I'm trying to get Google GPS API key in Google console, I have seen package name and SHA-1 key where to I get SHA-1 key in React Native

How to get SHA-1 key in React Native cli? (not in Expo).

like image 402
Balaji Avatar asked Feb 25 '19 14:02

Balaji


People also ask

How do I get SHA1 key in terminal?

Click on Tasks. Click on android. Double Click on signingReport. Wait for few seconds and you will get SHA1 and MD5 in Console Bar.

What is SHA1 KEY?

SHA-1 Keys SHA-1 also referred to as the Secure Hash Algorithm. It is a cryptographic hash function that will take input and it produces a 160-bit hash value. This generated hash value is known as a message digest. This generated hash value is then rendered in a hexadecimal format number which is 40 digits long.


8 Answers

  1. Windows:
    – Open a terminal window

    – Change the directory to the JDK bin directory. The path of the JDK depends upon the operating system you are using

    cd C:\Program Files\Java\jdk1.8.0_121\bin

    – Now we have to run the following command using the keytool.exe file in JDK/bin

    keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

    enter image description here

  2. Ubuntu/Mac

    – Open a terminal window

    – Now run the following command

    keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

    enter image description here

For more details click Here

  1. From React-native Project:
    – Run this command in React-Native App directory

    cd android && ./gradlew signingReport

    – copy the SHA1 from the debug key (This generates two variant keys. You can copy the 'SHA1' that belongs to the debugAndroidTest variant key option.)

like image 68
Vikas Bansal Avatar answered Oct 05 '22 11:10

Vikas Bansal


if your are Using react native and using keytool -list -v -keystore ./android/App/debug.keystore -alias androiddebugkey -storepass android -keypass android
there are Chances getting ERROR

to Avoid ERROR in WINDOWS

1)Run your Command Prompt As Administrator

  1. Navigate to your react-native project's root folder

3)cd android

4)type in ./gradlew signingReport

this will generate All kinds of SHA-1 And SHA-256 and many more details

like image 22
Imran Pasha I Avatar answered Oct 05 '22 10:10

Imran Pasha I


There is debug.keystore available by default in android => app folder so we can use it to generate SHA1 key.

The command is as follows

keytool -exportcert -keystore ./android/app/debug.keystore -list -v

It will ask for password so just press Enter.

like image 37
Hussain Badri Avatar answered Oct 05 '22 11:10

Hussain Badri


As far as I understand you, it's about Android.
You need input certificate fingerprint, what you use for sign *.apk file.
For generate SHA-1 fingerprint, open a terminal window and enter the following:

keytool -list -v -keystore PATH_TO_YOUR_KEYSTORE.keystore -alias YOUR_ALIAS_NAME -storepass YOUR_STORE_PASS -keypass YOUR_KEY_PASS

This should look something like this:

BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75

You can find more information here
If you don't have a certificate yet, I recommend you create it.
How to create a certificate you can read here.

like image 39
Evgeniy Bondarenko Avatar answered Oct 05 '22 10:10

Evgeniy Bondarenko


Get SHA1 Key

Simple run below command :

keytool -list -v -keystore ./android/App/debug.keystore -alias androiddebugkey -storepass android -keypass android
like image 24
ANKIT DETROJA Avatar answered Oct 05 '22 12:10

ANKIT DETROJA


Even though running keytool on jdk/bin and ./gradlew signingReport command gives SHA-1 & SHA-256 keys I had troubles when using those keys on firebase / gcp to register my app. For some reason running keytool command on project root folder output gives you a SHA-1 key which can be use to register the app in gcp. In windows, there are the steps you should follow

  1. Make sure keytool is the enviroment variable path
  2. Open the cmd in your root project folder (eg: C:/myreactnativeproject/)
  3. run keytool -list -v -keystore ./android/app/debug.keystore -alias androiddebugkey -storepass android -keypass android

And there is your SHA-1

like image 34
CharukaHS Avatar answered Oct 05 '22 12:10

CharukaHS


my solution: keytool -J-Duser.language=en -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

like image 42
Thanh Cao Avatar answered Oct 05 '22 12:10

Thanh Cao


first move to android folder cd android and than simply run .\gradlew signingReport command this help me on windows operating system

like image 41
f180362 Asad Ullah Avatar answered Oct 05 '22 12:10

f180362 Asad Ullah