Vitalik
9 months ago
5 changed files with 50 additions and 0 deletions
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
import { Platform } from 'react-native' |
||||
import { TranspositionCipher } from './tranposition-cipher.helper' |
||||
import DeviceInfo from 'react-native-device-info' |
||||
|
||||
export class UserFingerprintGenerator { |
||||
private static exist: string |
||||
|
||||
static generateUserFingerprint(): string { |
||||
if (this.exist) return this.exist |
||||
|
||||
const deviceId = DeviceInfo.getDeviceId() |
||||
|
||||
const fingerprint = `deviceId:::${deviceId}|platform:::${ |
||||
Platform.OS |
||||
}|brand:::${DeviceInfo.getBrand()}` |
||||
|
||||
console.log('fingerprint', fingerprint) |
||||
|
||||
const hashedFingerprint = this.hashFunction(fingerprint.trim()) |
||||
|
||||
this.exist = hashedFingerprint |
||||
return hashedFingerprint |
||||
} |
||||
|
||||
private static hashFunction(input: string): string { |
||||
return TranspositionCipher.encrypt(input) |
||||
} |
||||
} |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
import { encode, decode } from 'js-base64' |
||||
|
||||
export class TranspositionCipher { |
||||
static encrypt(message: string): string { |
||||
return encode(message) |
||||
} |
||||
|
||||
static decrypt(encryptedMessage: string): string { |
||||
return decode(encryptedMessage) |
||||
} |
||||
} |
Loading…
Reference in new issue