Quectel 5G module, open adb, you need to enter a key to open
python:
import crypt
#sn = '18700338'
#sn = '40901409'
sn = '12741851'
def generateUnlockKey(sn):
"""
@param sn: the serial number to generate an unlock key for
"""
salt = "$1${0}$".format(sn)
c = crypt.crypt("SH_adb_quectel", salt)
print("Salt: {0}\nCrypt: {1}\nCode: {2}\n".format(salt, c, c[12:27]))
return c[12:27]
xx = generateUnlockKey(sn)
print(xx)
def old_key(salt):
code = crypt.crypt("SH_adb_quectel", "$1$" + salt)
#code = crypt.crypt("SH_adb_quectel", "$1$" + salt + '$')
code = code[12:27]
return code
yy = old_key(sn)
print('jiandan=', yy)
c#”
using System;
using System.Security.Cryptography;
using System.Text;
class Program
{
static void Main()
{
string sn = "12741851";
string xx = GenerateUnlockKey(sn);
Console.WriteLine(xx);
string yy = OldKey(sn);
Console.WriteLine("jiandan=" + yy);
}
static string GenerateUnlockKey(string sn)
{
string salt = "$1$" + sn;
string key = GenerateHash("SH_adb_quectel", salt);
string code = key.Substring(12, 15);
Console.WriteLine("Salt: {0}\nCrypt: {1}\nCode: {2}\n", salt, key, code);
return code;
}
static string OldKey(string salt)
{
string key = GenerateHash("SH_adb_quectel", "$1$" + salt);
string code = key.Substring(12, 15);
return code;
}
static string GenerateHash(string password, string salt)
{
using (var rfc2898 = new Rfc2898DeriveBytes(password, Encoding.UTF8.GetBytes(salt), 10000, HashAlgorithmName.SHA256))
{
return Convert.ToBase64String(rfc2898.GetBytes(20));
}
}
}
