Smart App SDKFAQHow to Get SHA1 and SHA256 Keys

How to Get SHA1 and SHA256 Keys

Last Updated on : 2021-08-19 10:41:14download

This topic describes how to get the SHA1 and SHA256 keys. You can apply the keys to the created application that integrates with the IoT App SDK for Android in the Tuya IoT Platform to enhance security.

Key types

  • SHA1 is a data encryption algorithm. In this algorithm, the plaintext is received and converted into ciphertext. The text size is decreased in most cases. Hash values of shorter length and with a fixed number of bits are generated. For example, the Industry App SDK uses SHA1 keys.
  • SHA256 is a type of secure hash algorithm. The data encrypted with the SHA256 algorithm is converted into a fixed-size 256-bit binary value. The output varies depending on the input. This enhances data security. For example, the Smart Life App SDK and Commercial Lighting App SDK use SHA256 keys.

Generate a keystore file

  1. Open your application project in Android Studio.
  2. In the menu bar, choose Build > Generate Signed APK.
    How to Get SHA1 and SHA256 Keys
  3. Select APK and follow the instructions to create a keystore file. For more information, see the Generate an upload key and keystore section of Sign your App.
    How to Get SHA1 and SHA256 Keys

Get the SHA1 or SHA256 key

  1. In the same directory, run keytool to retrieve the generated .jks file.
    keytool -list -v -keystore  xx.jks
    Enter the password
    

    The keytool command is a tool to manage keys and certificates.

  2. Get the SHA1 or SHA256 key from the file.
    Valid from Tue Mar 16 10:22:14 CST 2021 to Sun Mar 06 10:22:14 CST 2061
    Certificate fingerprint:
    MD5: 6B:8C:94:15:35:7C:2E:E8:6E:76:7F:8C:F9:4B:05:BC
    SHA1: 8F:AC:5D:50:65:22:C2:2A:E4:96:3D:8F:9E:DC:5B:43:11:49:55:B1
    SHA256: 0B:98:89:D8:D5:FC:B1:23:9A:76:B1:2B:8F:4C:5E:24:BF:E7:60:E8:FF:EF:E9:40: 48:14:60:D3:62:00:5C:5F
    Signature algorithm name: SHA256withRSA
    Subject public key algorithm: 2048-bit RSA key
    Version: 3
    

Next step

Configure the SHA1 or SHA256 key on the Tuya IoT Platform: