123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Security.Cryptography;
- using System.Text;
- using UnityEngine;
- public class GetAndroidSNIEMI : MonoBehaviour
- {
-
- void Start()
- {
-
-
-
-
-
-
-
-
- StartCoroutine(PutDeviceID());
- }
- private IEnumerator PutDeviceID()
- {
- yield return new WaitForSeconds(3);
- string id = GetDeviceUniqueIdMD5();
- Debug.Log("DeviceId " + id);
- UILogManager.Instance.text3.text = id;
- }
- public static string GetDeviceUniqueIdMD5()
- {
- string id = SystemInfo.deviceUniqueIdentifier;
-
- return EncryptMD5_16(id);
- }
-
-
-
-
-
-
-
- private static string Encrypt(string sText, Encoding encoding, bool uppercase = false)
- {
- byte[] buffer = encoding.GetBytes(sText);
- string s = Encrypt(buffer);
-
-
- return s;
- }
-
-
-
-
-
- private static string Encrypt(byte[] buffer)
- {
-
- using (MD5 md5 = MD5.Create())
- {
-
- byte[] bufferNew = md5.ComputeHash(buffer);
- string s = BitConverter.ToString(bufferNew, 0, bufferNew.Length);
- return s.Replace("-", "");
- }
- }
-
-
-
-
-
- private static string Encrypt(Stream inputStream)
- {
- using (MD5 mi = MD5.Create())
- {
-
- byte[] bufferNew = mi.ComputeHash(inputStream);
- string s = BitConverter.ToString(bufferNew, 0, bufferNew.Length);
- return s.Replace("-", "");
- }
- }
-
-
-
-
-
- private static string EncryptMD5_16(string _encryptContent)
- {
- var md5 = new MD5CryptoServiceProvider();
- string t2 = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(_encryptContent)), 4, 8);
- t2 = t2.Replace("-", "");
- return t2;
- }
- }
|