How to generate SHA1 key in Flutter using gradlew signingReport ?

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.

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