How to Create SHA1 Key in android studio?

To get the SHA1 key in Flutter using gradlew signingReport, follow these steps:

  1. Open your Flutter project in Android Studio or VS Code.
  2. Open the terminal and navigate to the android directory of your Flutter project by running the following command:
cd <your_flutter_project>/android
  1. Run the following command to generate the SHA1 key:
./gradlew signingReport

This will generate a list of signing reports, which includes the SHA1 key, for all the variants of your app. Look for the report that corresponds to the variant that you are using (usually debug), and copy the SHA1 key.

Here’s an example of what the output of the command might look like:

> Task :app:signingReport
Variant: debugAndroidTest
Config: debug
Store: /Users/username/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 12:34:56:78:90:AB:CD:EF:12:34:56:78:90:AB:CD:EF
SHA1: 12:34:56:78:90:AB:CD:EF:12:34:56:78:90:AB:CD:EF:12:34:56:78:90
SHA-256: 12:34:56:78:90:AB:CD:EF:12:34:56:78:90:AB:CD:EF:12:34:56:78:90:AB:CD:EF:12:34:56:78:90:AB:CD:EF:12:34:56:78:90
Valid until: Wednesday, April 10, 2023

In this example, the SHA1 key is 12:34:56:78:90:AB:CD:EF:12:34:56:78:90:AB:CD:EF:12:34:56:78:90.

Note: If you are using Windows, replace ./gradlew with gradlew.bat in the command.

if you want to generate SHA1 key from any string then use crypto package.

import 'dart:convert';
import 'package:crypto/crypto.dart';

void main() {
  String input = "Your Input String"; // Replace with your input string
  var bytes = utf8.encode(input); // Convert the input string to bytes
  var sha1 = sha1.convert(bytes); // Generate the SHA1 hash
  var sha1String = sha1.toString(); // Convert the hash to a string
  print(sha1String); // Print the SHA1 hash
}

Replace "Your Input String" with the input string for which you want to generate the SHA1 key.

When you run the code, it will print the SHA1 hash of the input string. You can then use this SHA1 key for your desired purpose.

Note: The crypto package is not included in Flutter by default. You will need to add it to your pubspec.yaml file and run flutter pub get to download and install it.

How To Use ./Gradlew SigningReport Command For SHA1 Key Generator?

The command ./gradlew signingReport is used in Android development with Gradle to generate a report that provides information about the signing configurations of your Android app.

When you build an Android app for release, you typically sign it with a digital certificate to ensure its authenticity and integrity. The signing process involves generating a keystore file that contains the digital certificate used to sign the app. This certificate is important when releasing updates or distributing your app through official channels like the Google Play Store.

By running the ./gradlew signingReport command, Gradle analyzes your project’s configuration and provides a report that includes details about the signing configurations in use. This report includes information such as the keystore file used for signing, the signing key’s alias, validity dates, and other relevant details.

The signing report is useful for verifying the signing configurations in your app and ensuring that they are correctly set up. It can help identify any issues or inconsistencies in your signing configuration, such as expired or mismatched certificates.

To execute the ./gradlew signingReport command, you typically navigate to the root directory of your Android project in a terminal or command prompt and run the command specific to your operating system (gradlew signingReport for Windows or ./gradlew signingReport for macOS/Linux). Gradle then generates the report, which you can review in the console output to examine the signing configurations of your Android app.

How to Generate SHA-1 Key in Flutter?

SHA-1(Secure Hash Algorithm) is the unique identity of your Application. In Flutter, you can use these keys for various purposes such as adding Firebase to your app, Google Maps API integration, and more. For example, to add Firebase to your app, you need to provide the SHA-1 and SHA-256 keys to the Firebase console during setup. It generates a 160-bit Hash Value. These are the very secure Key values. If you are creating any Professional App then you should not share it with anyone as it may result in hacking of your  Application.

Note that SHA-1 is considered insecure and should not be used for new applications. SHA-256 is the recommended cryptographic hash function for generating secure digital signatures and message authentication codes Or you may say that SHA-256 is more secure than SHA-1 as SHA-256 generates a 256-bit hash value. There are various ways to generate SHA-1 keys and SHA-256 keys. In the case of Flutter Apps, it is quite difficult as compared to Android. So we will tell you how to generate both of these using a single command only in Flutter Apps.

Generate SHA-1 for Flutter/React-Native/Android-Native app

TERMINAL

Go to the project folder in the terminal.

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

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

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

GUI Android Studio.

  1. Select android/app/build.gradle file and on the right top corner click “Open for Editing in Android Studio”

Go to the terminal view and paste: gradlew signingReport or ./gradlew signingReport if you’re using PowerShell or a Unix-based system like mac.

How to Get SHA-1 key in Android Studio for Firebase?

here are two methods of getting SHA-1 key, but First one is not working for Windows user. So, if you are a Windows user then go for 2nd Method.

Update:- On Android Studio Latest version(on 24 Sept 2021) 2020.3.1 for Windows 64-bit (912 MiB)Step 2 will not Work. So, go for Step 3.

1. Using Keytool

Open a terminal and run the keytool the utility provided with Java to get the SHA-1 fingerprint of the certificate. You should get both the release and debug certificate fingerprints.

To get the release certificate fingerprint:

For Windows:-

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

For Mac/Linux:-

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

Note:- If you are not able to get your SHA-1 key using Keytool then Follow the below Method, in this method you will definitely get your SHA-1 key.

2. Using Gradle’s Signing Report

You can also get the SHA-1 of your signing certificate by Gradle signingReport. But for that, you have to follow some steps.

Step 1: – First of all
=> open your project in Android Studio and open the project.
=>In the project, go to the android/app directory where you find build.gradle file. => Open it.
=> After opening, you’ll find an Open for Editing in Android Studio option, Click on it and open it in a new Tab. See the Below Image.

After Clicking on it, you’ll get a List of SHA-1 Keys but you have to choose Debug-Debug SHA-1 Key and copy and paste it on your Firebase. See the Below Image:-

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More