forked from scratchfoundation/scratch-flash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding util file that generates a unique id
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Created by samohan on 9/18/17. | ||
*/ | ||
package util { | ||
import flash.net.InterfaceAddress; | ||
import flash.net.NetworkInfo; | ||
import flash.net.NetworkInterface; | ||
import com.adobe.crypto.MD5; | ||
import flash.crypto.generateRandomBytes; | ||
|
||
public class OfflineTelemetry { | ||
public static function makeId():String { | ||
var timestamp:Number = (new Date()).time; | ||
var netInterfaces:Vector.<NetworkInterface> = NetworkInfo.networkInfo.findInterfaces(); | ||
var addresses:Vector.<InterfaceAddress> = netInterfaces[1].addresses; | ||
var hashedIpAddress:String = MD5.hash(addresses[0].address + generateRandomBytes(16).toString()); | ||
var hashedTimestamp:String = MD5.hash(timestamp.toString() + generateRandomBytes(16).toString()); | ||
var randomHashedString:String = MD5.hash(generateRandomBytes(16).toString()); | ||
return hashedIpAddress + "-" + hashedTimestamp + "-" + randomHashedString; | ||
} | ||
} | ||
} |