mirror of
https://github.com/selfxyz/self.git
synced 2026-04-27 03:01:15 -04:00
scripts that convert mrz to correct dataHash, but can't get to econtent now
This commit is contained in:
288
app/scripts/script.ts
Normal file
288
app/scripts/script.ts
Normal file
@@ -0,0 +1,288 @@
|
||||
// const crypto = require('crypto');
|
||||
import * as crypto from 'crypto';
|
||||
|
||||
const firstName = 'FLORENTHUGUESJEAN';
|
||||
const lastName = 'TAVERNIER';
|
||||
const gender = 'MALE';
|
||||
const issuer = 'FRA';
|
||||
const nationality = 'FRA';
|
||||
const photo = {
|
||||
base64:
|
||||
'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4gIoSUNDX1BST0ZJTEUAAQEAAAIYAAAAAAIQAABtbnRyUkdCIFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAAHRyWFlaAAABZAAAABRnWFlaAAABeAAAABRiWFlaAAABjAAAABRyVFJDAAABoAAAAChnVFJDAAABoAAAAChiVFJDAAABoAAAACh3dHB0AAAByAAAABRjcHJ0AAAB3AAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAFgAAAAcAHMAUgBHAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFhZWiAAAAAAAABvogAAOPUAAAOQWFlaIAAAAAAAAGKZAAC3hQAAGNpYWVogAAAAAAAAJKAAAA+EAAC2z3BhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABYWVogAAAAAAAA9tYAAQAAAADTLW1sdWMAAAAAAAAAAQAAAAxlblVTAAAAIAAAABwARwBvAG8AZwBsAGUAIABJAG4AYwAuACAAMgAwADEANv/bAEMA///////////////////////////////////////////////////////////////////////////////////////bAEMB///////////////////////////////////////////////////////////////////////////////////////AABEIAUAA8AMBIgACEQEDEQH/xAAXAAEBAQEAAAAAAAAAAAAAAAAAAQID/8QAIRABAQABAwQDAQAAAAAAAAAAAAERAhJhMYGh8CFB0VH/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAf/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/ANmRAXJlFAAAAAAAAAAAEAUQBcmUAXJlAFyIAogCiAKIAqKgCoAoAAACKgKIAAAAAAAAAAAAAAAAAAAqKAgKAigAIADFoN5kZ3MgLupuqANbqu5gB0zBzMg6DE1YbAAAAAAAAAABQQAAFEAAtc7bQW3LIAAAAAAAAALLhAHSVXJqXANhLkAAAAAABQAQFBALcAzqv0wdQAAAAAAAAAAAFBBcICyukuXNZcA2AAAACgIqAAAMar9NuYIAAAAAALhcAyq4XAMmGsAJhcKAmEsaKDCNVkG9N+mnJ0lzAUABUUBFQAAC9HJvV0YAAAFMZBMNyEigAIoKAgoCKigIqKJWHRiiI1prIDqEAAABUAABjV1Zb1MAA1AMNIoAACoCqIAoggAKAAgxW2KCAsB0nQJ0AAAUEBUAGdTC6rmoBG2Z1aBREBcmWcGAayZZUGhAVUyIIZMphcAZXKAKzWkoMrIjpOgKAAACgAIqAxq+mWtXVkFjTMaATKpATItiSAKAKqKKyKgiCpgF5MqmAVKqUEb09HN009AUAAAFAARUBnVPth0vRzoLG2I0AKAiKAigAqKKgAIoCAKAzWmaCRudGI6QAAAAFRQBFARit1kGY0z0aBQBUFAQABUUEAAVFABAGa0n2ISNsxoAAAAFAARUASxQGaLhAFQBUAUBKCjKiKMqKoAAAgDUAgAAAAAKAAigIAAipQQAAAAAEFQFEUUAAAEGmY0AAAAAACgAIqAAAAAyLUABAPkAE+RQEUAFQBQAWKAAAAAAAKAAioAAAADNv0jOfloFEABQEFAQUBAAFlRJfkHQAAAAAAAFQAAAAS3AKl6VjdUttBGpWQGxnKgqoAqACoAAiZAtQAdZ0ipLmKAAAAAAACWyAqZwxdX8QGrq/jAAAAAAAA1KrC5BpEyZBTKZQFQAAAGpq/rIDqrlLY3NQNAAAAxdX8YAAAAAAAAAAAAAAAAAAAAAAAAAFlsdJcuQDsMTV/W5cg4jrsnPvY2Tn3sDkOuyc+9jZOfH4DkOuyc+9jZOfH4DkOuyc+9jZOfewOQ67Jz72Nk597A5DrsnPj8Nk58fgOQ67Jz72Nk597A5DrsnPvY2Tnx+A5DrsnPj8Nk58fgOQ67Jz72Nk597A5DrsnPvY2Tn3sDkOuyc+9jZOfewOQ67Jz4/DZOfH4DkOuyc+Pw2Tn3sDksvy6bJz72Nk597A//Z',
|
||||
height: 320,
|
||||
width: 240,
|
||||
};
|
||||
const dg1File = {
|
||||
length: 91,
|
||||
mrzInfo: {
|
||||
compositeCheckDigit: '2',
|
||||
dateOfBirth: '000719',
|
||||
dateOfBirthCheckDigit: '1',
|
||||
dateOfExpiry: '291209',
|
||||
dateOfExpiryCheckDigit: '5',
|
||||
documentCode: 'P',
|
||||
documentNumber: '19HA34828',
|
||||
documentNumberCheckDigit: '4',
|
||||
documentType: 3,
|
||||
gender: 'MALE',
|
||||
issuingState: 'FRA',
|
||||
nationality: 'FRA',
|
||||
optionalData1: '<<<<<<<<<<<<<<0',
|
||||
primaryIdentifier: 'TAVERNIER',
|
||||
secondaryIdentifier: 'FLORENT<HUGUES<JEAN<<<<<<<<<',
|
||||
},
|
||||
tag: 97,
|
||||
};
|
||||
const publicKey =
|
||||
'RSA Public Key [81:f8:a9:ad:98:ce:a1:f8:41:b7:41:73:c8:4e:a9:a8:c9:32:c3:a2],[56:66:d1:a4]';
|
||||
const modulus =
|
||||
'df11ba06d7937a059e8ce7916ab0fb0b094a9b9ecf98e97eda6834a23075f2030072a3c7868f85045af2acb5f5c2bedf6c25614d99232b98bb456e5f8ce32148882f2281537ac7aa80e4cdb79e0cdf4627cd08da32ce263ef54a26c2ca3493f1d02d9fabcd89952058cb0085fa356b13f9e2cc1e9ca4f47678dc49129d55531bd2817dd436d5aef778d4d439d2d659b0cf9d58eeff43ce2cff26d5c66d23164123fc9c3e6cd4902e9d7b54d9509b03f95debfc3fb15ef7b458ac64a2c6e26bf010451eff67ed87f6ca7a946dd7ac86dea2566cbdc9aa0e3cbaad9f5ed4b6886cd08f6baf1487b58f6ba33075968396c216ef65b0eb49c6978464dcde99f9a9a1';
|
||||
const exponent = 10001;
|
||||
const publicKeyOldSchool =
|
||||
'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3xG6BteTegWejOeRarD7CwlKm57PmOl+2mg0ojB18gMAcqPHho+FBFryrLX1wr7fbCVhTZkjK5i7RW5fjOMhSIgvIoFTeseqgOTNt54M30YnzQjaMs4mPvVKJsLKNJPx0C2fq82JlSBYywCF+jVrE/nizB6cpPR2eNxJEp1VUxvSgX3UNtWu93j1DnS1lmwz51Y7v9Dziz/JtXGbSMWQSP8nD5s1JAunXtU2VCbA/ld6/w/sV73tFisZKLG4mvwEEUe/2fth/bKepRt16yG3qJWbL3Jqg48uq2fXtS2iGzQj2uvFIe1j2ujMHWWg5bCFu9lsOtJxpeEZNzemfmpoQIDAQAB';
|
||||
const dataGroupHashes = {
|
||||
'1': [
|
||||
99, 19, -77, -51, 55, 104, 45, -42, -123, 101, -23, -79, -126, 1, 37, 89,
|
||||
125, -27, -117, 34, -124, -110, 28, 116, -8, -70, 63, -61, 96, -105, 26,
|
||||
-41,
|
||||
],
|
||||
'11': [
|
||||
0, -62, 104, 108, -19, -10, 97, -26, 116, -58, 69, 110, 26, 87, 17, 89, 110,
|
||||
-57, 108, -6, 36, 21, 39, 87, 110, 102, -6, -43, -82, -125, -85, -82,
|
||||
],
|
||||
'12': [
|
||||
-66, 82, -76, -21, -34, 33, 79, 50, -104, -120, -114, 35, 116, -32, 6, -14,
|
||||
-100, -115, -128, -9, 10, 61, 98, 86, -8, 45, -49, -46, 90, -24, -81, 38,
|
||||
],
|
||||
'13': [
|
||||
91, -34, -46, -63, 63, -34, 104, 82, 36, 41, -118, -3, 70, 15, -108, -48,
|
||||
-100, 45, 105, -85, -15, -61, -71, 43, -39, -94, -110, -55, -34, 89, -18,
|
||||
38,
|
||||
],
|
||||
'14': [
|
||||
76, 123, -40, 13, 52, -29, 72, -11, 59, -63, -18, -90, 103, 49, 24, -92,
|
||||
-85, -68, -62, -59, -100, -69, -7, 28, -58, 95, 69, 15, -74, 56, 54, 38,
|
||||
],
|
||||
'2': [
|
||||
63, -22, 106, 78, 31, 16, 114, -119, -19, 17, 92, 71, -122, 47, 62, 78, -67,
|
||||
-23, -55, -43, 53, 4, 47, -67, -55, -123, 6, 121, 34, -125, 64, -114,
|
||||
],
|
||||
'3': [
|
||||
-120, -101, 87, -112, 121, 15, -104, 127, 85, 25, -102, 80, 20, 58, 51, 75,
|
||||
-63, 116, -22, 0, 60, 30, 29, 30, -73, -115, 72, -9, -1, -53, 100, 124,
|
||||
],
|
||||
};
|
||||
const eContent =
|
||||
'3166301506092a864886f70d01090331080606678108010101301c06092a864886f70d010905310f170d3139313231363137323233385a302f06092a864886f70d01090431220420b0603bd5835259f8697d25b19ea2892b0d2773063be5516e314bffb89b497456';
|
||||
const encryptedDigest =
|
||||
'5a78c5d241463136f26255cb75fe2de2dbaeda10ef7c7eea2f6b635940e079b04d6bfec592ef1293366076382e2a9543bd84a973c66e6c0715e468738c5d802c98cd81aa3d338a4e338e93e219412835456c4a0208587c360a5b8d4c2d09d069671e4175104c69c8ad2dadc6dea40729463dd8543392420406c08a020dadcb14ec78fad95ccef0cbe06a5416c45a9abc31c38d88190cb650a6536f0357bb6a04c59817a889d2eee4128b7757b2f7b52e572b030ef7b362dbad20de3a2a2c488134042fb8b18a254d2332cde4996e768da37863419a2760b9f394de395425db5b8276a24b60f02a0b595bf81a28dc3bd7584863641a75504b0df267467de87516';
|
||||
|
||||
// Assemble the MRZ in two lines
|
||||
// let mrzLine1 =
|
||||
// dg1File.mrzInfo.documentCode +
|
||||
// dg1File.mrzInfo.issuingState +
|
||||
// dg1File.mrzInfo.primaryIdentifier +
|
||||
// dg1File.mrzInfo.optionalData1.toUpperCase();
|
||||
|
||||
// let mrzLine2 =
|
||||
// dg1File.mrzInfo.documentNumber +
|
||||
// dg1File.mrzInfo.documentNumberCheckDigit +
|
||||
// dg1File.mrzInfo.nationality +
|
||||
// dg1File.mrzInfo.dateOfBirth +
|
||||
// dg1File.mrzInfo.dateOfBirthCheckDigit +
|
||||
// dg1File.mrzInfo.gender +
|
||||
// dg1File.mrzInfo.dateOfExpiry +
|
||||
// dg1File.mrzInfo.dateOfExpiryCheckDigit +
|
||||
// dg1File.mrzInfo.secondaryIdentifier.toUpperCase() +
|
||||
// dg1File.mrzInfo.compositeCheckDigit;
|
||||
|
||||
// Form the MRZ string
|
||||
// const mrzString = `${dg1File.mrzInfo.documentCode}<${dg1File.mrzInfo.issuingState}${dg1File.mrzInfo.primaryIdentifier}<<${dg1File.mrzInfo.secondaryIdentifier}\n${dg1File.mrzInfo.documentNumber}${dg1File.mrzInfo.documentNumberCheckDigit}${dg1File.mrzInfo.nationality}${dg1File.mrzInfo.dateOfBirth}${dg1File.mrzInfo.dateOfBirthCheckDigit}${dg1File.mrzInfo.gender}${dg1File.mrzInfo.dateOfExpiry}${dg1File.mrzInfo.dateOfExpiryCheckDigit}${dg1File.mrzInfo.optionalData1}${dg1File.mrzInfo.compositeCheckDigit}`;
|
||||
|
||||
// console.log('MRZ string:', mrzString);
|
||||
|
||||
// // Convert the MRZ string to a byte array
|
||||
// const mrzByteArray = Array.from(Buffer.from(mrzString, 'utf8'));
|
||||
|
||||
// console.log('MRZ byte array:', mrzByteArray);
|
||||
|
||||
// // Hash the MRZ byte array using SHA-256
|
||||
// const sha256 = crypto.createHash('sha256');
|
||||
// sha256.update(Buffer.from(mrzByteArray));
|
||||
// const hash = sha256.digest();
|
||||
|
||||
// // Convert the hash to a byte array
|
||||
// const hashByteArray = Array.from(hash);
|
||||
|
||||
// console.log('Hash byte array:', hashByteArray);
|
||||
|
||||
// The MRZ information
|
||||
// const mrz =
|
||||
// 'P<FRATAVERNIER<<FLORENT<HUGUES<JEAN<<<<<<<<<\n19HA348284FRA0007191M2912095<<<<<<<<<<<<<<02';
|
||||
|
||||
// // Convert the MRZ information to a Buffer
|
||||
// const mrzBuffer = Buffer.from(mrz);
|
||||
|
||||
// // Create a SHA-256 hash of the MRZ information
|
||||
// const hash = crypto.createHash('sha256').update(mrzBuffer).digest('hex');
|
||||
|
||||
// console.log(hash);
|
||||
|
||||
// let sodFile = {
|
||||
// digestAlgorithm: 'sha256',
|
||||
// // assuming dataGroupHashes is an array of data groups. Initialize it as needed
|
||||
// dataGroupHashes: [],
|
||||
// };
|
||||
|
||||
// let dg1File = {
|
||||
// encoded: Buffer.from([
|
||||
// 97, 91, 95, 31, 88, 80, 60, 70, 82, 65, 84, 65, 86, 69, 82, 78, 73, 69, 82,
|
||||
// 60, 60, 70, 76, 79, 82, 69, 78, 84, 60, 72, 85, 71, 85, 69, 83, 60, 74, 69,
|
||||
// 65, 78, 60, 60, 60, 60, 60, 60, 60, 60, 60, 49, 57, 72, 65, 51, 52, 56, 50,
|
||||
// 56, 52, 70, 82, 65, 48, 48, 48, 55, 49, 57, 49, 77, 50, 57, 49, 50, 48, 57,
|
||||
// 53, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 48, 50,
|
||||
// ]),
|
||||
// };
|
||||
|
||||
// // dataGroupHashes["1"] c'est dg1.encoded (hash du DG1 ?)
|
||||
|
||||
// let digest = crypto.createHash(sodFile.digestAlgorithm);
|
||||
// let dg1Hash = digest.update(dg1File.encoded).digest();
|
||||
|
||||
// console.log('dg1Hash:', dg1Hash.toString('hex'));
|
||||
|
||||
// function encodeDg1File(dg1File: any) {
|
||||
// // Convert the MRZ Info to a string in the MRZ format
|
||||
// let mrzString =
|
||||
// dg1File.mrzInfo.documentCode +
|
||||
// dg1File.mrzInfo.issuingState +
|
||||
// dg1File.mrzInfo.primaryIdentifier +
|
||||
// '<<' +
|
||||
// dg1File.mrzInfo.secondaryIdentifier +
|
||||
// dg1File.mrzInfo.documentNumber +
|
||||
// dg1File.mrzInfo.documentNumberCheckDigit +
|
||||
// dg1File.mrzInfo.nationality +
|
||||
// dg1File.mrzInfo.dateOfBirth +
|
||||
// dg1File.mrzInfo.dateOfBirthCheckDigit +
|
||||
// dg1File.mrzInfo.gender +
|
||||
// dg1File.mrzInfo.dateOfExpiry +
|
||||
// dg1File.mrzInfo.dateOfExpiryCheckDigit +
|
||||
// dg1File.mrzInfo.optionalData1 +
|
||||
// dg1File.mrzInfo.compositeCheckDigit;
|
||||
|
||||
// // Replace < characters with ASCII code for <
|
||||
// mrzString = mrzString.replace(/</g, String.fromCharCode(60));
|
||||
|
||||
// // Create a new array of ASCII codes from the MRZ string
|
||||
// let encoded = [];
|
||||
// for (let i = 0; i < mrzString.length; i++) {
|
||||
// encoded.push(mrzString.charCodeAt(i));
|
||||
// }
|
||||
|
||||
// // Return the encoded array
|
||||
// return encoded;
|
||||
// }
|
||||
|
||||
// const encoded = encodeDg1File(dg1File);
|
||||
|
||||
// const encodedString = encoded.map(code => String.fromCharCode(code)).join('');
|
||||
|
||||
// console.log('encodedString', encodedString);
|
||||
|
||||
// const hash = crypto.createHash('sha256');
|
||||
// hash.update(encodedString);
|
||||
// const hashedEncoded = hash.digest('hex');
|
||||
|
||||
// console.log('hashedEncoded', hashedEncoded);
|
||||
|
||||
// const hash2 = crypto.createHash('sha256');
|
||||
// hash2.update(Buffer.from(encoded));
|
||||
// const hashedEncoded2 = hash2.digest('hex');
|
||||
|
||||
// console.log('hashedEncoded2', hashedEncoded2);
|
||||
|
||||
function getEncoded(dg1File: any) {
|
||||
let buffers = [];
|
||||
|
||||
// helper to write string as ASCII codes
|
||||
const write = (str: string) => {
|
||||
buffers.push(Buffer.from(str, 'utf8'));
|
||||
};
|
||||
|
||||
// helper to write '<' filled string of certain length
|
||||
const writeFixedSize = (str: any, size: any) => {
|
||||
str = str.padEnd(size, '<');
|
||||
buffers.push(Buffer.from(str, 'utf8'));
|
||||
};
|
||||
|
||||
const writeDocumentType = () => write(dg1File.mrzInfo.documentCode);
|
||||
const writeIssuingState = () => write(dg1File.mrzInfo.issuingState);
|
||||
const writeDocumentNumber = () =>
|
||||
writeFixedSize(dg1File.mrzInfo.documentNumber, 9);
|
||||
const writeDateOfBirth = () => write(dg1File.mrzInfo.dateOfBirth);
|
||||
const writeGender = () => write(dg1File.mrzInfo.gender);
|
||||
const writeDateOfExpiry = () => write(dg1File.mrzInfo.dateOfExpiry);
|
||||
const writeNationality = () => write(dg1File.mrzInfo.nationality);
|
||||
const writeName = () =>
|
||||
writeFixedSize(
|
||||
dg1File.mrzInfo.primaryIdentifier +
|
||||
'<<' +
|
||||
dg1File.mrzInfo.secondaryIdentifier,
|
||||
39,
|
||||
);
|
||||
|
||||
if (dg1File.mrzInfo.documentType === 3) {
|
||||
// check if it's an ID3 document
|
||||
writeDocumentType();
|
||||
writeIssuingState();
|
||||
writeName();
|
||||
writeDocumentNumber();
|
||||
buffers.push(
|
||||
Buffer.from([dg1File.mrzInfo.documentNumberCheckDigit.charCodeAt(0)]),
|
||||
); // Convert string digit to ASCII code
|
||||
writeNationality();
|
||||
writeDateOfBirth();
|
||||
buffers.push(
|
||||
Buffer.from([dg1File.mrzInfo.dateOfBirthCheckDigit.charCodeAt(0)]),
|
||||
); // Convert string digit to ASCII code
|
||||
writeGender();
|
||||
writeDateOfExpiry();
|
||||
buffers.push(
|
||||
Buffer.from([dg1File.mrzInfo.dateOfExpiryCheckDigit.charCodeAt(0)]),
|
||||
); // Convert string digit to ASCII code
|
||||
// assuming personal number is optionalData1
|
||||
writeFixedSize(dg1File.mrzInfo.optionalData1, 14);
|
||||
// assuming personal number check digit is missing
|
||||
buffers.push(
|
||||
Buffer.from([dg1File.mrzInfo.compositeCheckDigit.charCodeAt(0)]),
|
||||
); // Convert string digit to ASCII code
|
||||
} else {
|
||||
console.error('Unsupported document type: ', dg1File.mrzInfo.documentType);
|
||||
}
|
||||
|
||||
return Buffer.concat(buffers);
|
||||
}
|
||||
|
||||
const encoded = Array.from(getEncoded(dg1File));
|
||||
console.log(encoded);
|
||||
const a = [
|
||||
80, 70, 82, 65, 84, 65, 86, 69, 82, 78, 73, 69, 82, 60, 60, 70, 76, 79, 82,
|
||||
69, 78, 84, 60, 72, 85, 71, 85, 69, 83, 60, 74, 69, 65, 78, 60, 60, 60, 60,
|
||||
60, 60, 60, 60, 60, 49, 57, 72, 65, 51, 52, 56, 50, 56, 4, 70, 82, 65, 48, 48,
|
||||
48, 55, 49, 57, 1, 77, 65, 76, 69, 50, 57, 49, 50, 48, 57, 5, 60, 60, 60, 60,
|
||||
60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 48, 2,
|
||||
];
|
||||
|
||||
console.log('a', a.map(code => String.fromCharCode(code)).join(''));
|
||||
|
||||
const b = [
|
||||
97, 91, 95, 31, 88, 80, 60, 70, 82, 65, 84, 65, 86, 69, 82, 78, 73, 69, 82,
|
||||
60, 60, 70, 76, 79, 82, 69, 78, 84, 60, 72, 85, 71, 85, 69, 83, 60, 74, 69,
|
||||
65, 78, 60, 60, 60, 60, 60, 60, 60, 60, 60, 49, 57, 72, 65, 51, 52, 56, 50,
|
||||
56, 52, 70, 82, 65, 48, 48, 48, 55, 49, 57, 49, 77, 50, 57, 49, 50, 48, 57,
|
||||
53, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 48, 50,
|
||||
];
|
||||
console.log('b', b.map(code => String.fromCharCode(code)).join(''));
|
||||
|
||||
// PFRATAVERNIER<<FLORENT<HUGUES<JEAN<<<<<<<<<19HA34828FRA000719MALE291209<<<<<<<<<<<<<<0
|
||||
// a[_XP<FRATAVERNIER<<FLORENT<HUGUES<JEAN<<<<<<<<<19HA348284FRA0007191M2912095<<<<<<<<<<<<<<02
|
||||
347
app/scripts/script2.ts
Normal file
347
app/scripts/script2.ts
Normal file
@@ -0,0 +1,347 @@
|
||||
import * as crypto from 'crypto';
|
||||
|
||||
// On a la donnée de base :
|
||||
const dg1File = {
|
||||
length: 91,
|
||||
mrzInfo: {
|
||||
compositeCheckDigit: '2',
|
||||
dateOfBirth: '000719',
|
||||
dateOfBirthCheckDigit: '1',
|
||||
dateOfExpiry: '291209',
|
||||
dateOfExpiryCheckDigit: '5',
|
||||
documentCode: 'P',
|
||||
documentNumber: '19HA34828',
|
||||
documentNumberCheckDigit: '4',
|
||||
documentType: 3,
|
||||
gender: 'MALE',
|
||||
issuingState: 'FRA',
|
||||
nationality: 'FRA',
|
||||
optionalData1: '<<<<<<<<<<<<<<0',
|
||||
primaryIdentifier: 'TAVERNIER',
|
||||
secondaryIdentifier: 'FLORENT<HUGUES<JEAN<<<<<<<<<',
|
||||
},
|
||||
tag: 97,
|
||||
};
|
||||
const mrzInfo = dg1File.mrzInfo;
|
||||
|
||||
// 'P<FRATAVERNIER<<FLORENT<HUGUES<JEAN<<<<<<<<<19HA348284FRA0007191M2912095<<<<<<<<<<<<<<02';
|
||||
const mrz =
|
||||
mrzInfo.documentCode +
|
||||
'<' +
|
||||
mrzInfo.issuingState +
|
||||
mrzInfo.primaryIdentifier +
|
||||
'<<' +
|
||||
mrzInfo.secondaryIdentifier +
|
||||
mrzInfo.documentNumber +
|
||||
mrzInfo.documentNumberCheckDigit +
|
||||
mrzInfo.nationality +
|
||||
mrzInfo.dateOfBirth +
|
||||
mrzInfo.dateOfBirthCheckDigit +
|
||||
mrzInfo.gender.substring(0, 1) +
|
||||
mrzInfo.dateOfExpiry +
|
||||
mrzInfo.dateOfExpiryCheckDigit +
|
||||
mrzInfo.optionalData1 +
|
||||
mrzInfo.compositeCheckDigit;
|
||||
|
||||
console.log('mrz: ', mrz);
|
||||
|
||||
const mrzCharcodes = [...mrz].map(char => char.charCodeAt(0));
|
||||
|
||||
console.log('mrzCharcodes:', mrzCharcodes);
|
||||
|
||||
mrzCharcodes.unshift(88); // the length of the mrz data
|
||||
mrzCharcodes.unshift(95, 31); // the MRZ_INFO_TAG
|
||||
mrzCharcodes.unshift(91); // the new length of the whole array
|
||||
mrzCharcodes.unshift(97); // the tag for DG1
|
||||
|
||||
console.log('mrzCharcodes with tags:', mrzCharcodes);
|
||||
|
||||
const hash = crypto.createHash('sha256');
|
||||
hash.update(Buffer.from(mrzCharcodes));
|
||||
const dataHash = hash.digest('hex');
|
||||
|
||||
console.log('dataHash:', dataHash);
|
||||
// C'est bien dataHashes["1"]
|
||||
|
||||
const dataHashes = {
|
||||
'1': [
|
||||
99, 19, -77, -51, 55, 104, 45, -42, -123, 101, -23, -79, -126, 1, 37, 89,
|
||||
125, -27, -117, 34, -124, -110, 28, 116, -8, -70, 63, -61, 96, -105, 26,
|
||||
-41,
|
||||
],
|
||||
'2': [
|
||||
63, -22, 106, 78, 31, 16, 114, -119, -19, 17, 92, 71, -122, 47, 62, 78, -67,
|
||||
-23, -55, -43, 53, 4, 47, -67, -55, -123, 6, 121, 34, -125, 64, -114,
|
||||
],
|
||||
'3': [
|
||||
-120, -101, 87, -112, 121, 15, -104, 127, 85, 25, -102, 80, 20, 58, 51, 75,
|
||||
-63, 116, -22, 0, 60, 30, 29, 30, -73, -115, 72, -9, -1, -53, 100, 124,
|
||||
],
|
||||
'11': [
|
||||
0, -62, 104, 108, -19, -10, 97, -26, 116, -58, 69, 110, 26, 87, 17, 89, 110,
|
||||
-57, 108, -6, 36, 21, 39, 87, 110, 102, -6, -43, -82, -125, -85, -82,
|
||||
],
|
||||
'12': [
|
||||
-66, 82, -76, -21, -34, 33, 79, 50, -104, -120, -114, 35, 116, -32, 6, -14,
|
||||
-100, -115, -128, -9, 10, 61, 98, 86, -8, 45, -49, -46, 90, -24, -81, 38,
|
||||
],
|
||||
'13': [
|
||||
91, -34, -46, -63, 63, -34, 104, 82, 36, 41, -118, -3, 70, 15, -108, -48,
|
||||
-100, 45, 105, -85, -15, -61, -71, 43, -39, -94, -110, -55, -34, 89, -18,
|
||||
38,
|
||||
],
|
||||
'14': [
|
||||
76, 123, -40, 13, 52, -29, 72, -11, 59, -63, -18, -90, 103, 49, 24, -92,
|
||||
-85, -68, -62, -59, -100, -69, -7, 28, -58, 95, 69, 15, -74, 56, 54, 38,
|
||||
],
|
||||
};
|
||||
|
||||
const dataHashesAsArray = [
|
||||
[
|
||||
99, 19, -77, -51, 55, 104, 45, -42, -123, 101, -23, -79, -126, 1, 37, 89,
|
||||
125, -27, -117, 34, -124, -110, 28, 116, -8, -70, 63, -61, 96, -105, 26,
|
||||
-41,
|
||||
],
|
||||
[
|
||||
63, -22, 106, 78, 31, 16, 114, -119, -19, 17, 92, 71, -122, 47, 62, 78, -67,
|
||||
-23, -55, -43, 53, 4, 47, -67, -55, -123, 6, 121, 34, -125, 64, -114,
|
||||
],
|
||||
[
|
||||
-120, -101, 87, -112, 121, 15, -104, 127, 85, 25, -102, 80, 20, 58, 51, 75,
|
||||
-63, 116, -22, 0, 60, 30, 29, 30, -73, -115, 72, -9, -1, -53, 100, 124,
|
||||
],
|
||||
[
|
||||
0, -62, 104, 108, -19, -10, 97, -26, 116, -58, 69, 110, 26, 87, 17, 89, 110,
|
||||
-57, 108, -6, 36, 21, 39, 87, 110, 102, -6, -43, -82, -125, -85, -82,
|
||||
],
|
||||
[
|
||||
-66, 82, -76, -21, -34, 33, 79, 50, -104, -120, -114, 35, 116, -32, 6, -14,
|
||||
-100, -115, -128, -9, 10, 61, 98, 86, -8, 45, -49, -46, 90, -24, -81, 38,
|
||||
],
|
||||
[
|
||||
91, -34, -46, -63, 63, -34, 104, 82, 36, 41, -118, -3, 70, 15, -108, -48,
|
||||
-100, 45, 105, -85, -15, -61, -71, 43, -39, -94, -110, -55, -34, 89, -18,
|
||||
38,
|
||||
],
|
||||
[
|
||||
76, 123, -40, 13, 52, -29, 72, -11, 59, -63, -18, -90, 103, 49, 24, -92,
|
||||
-85, -68, -62, -59, -100, -69, -7, 28, -58, 95, 69, 15, -74, 56, 54, 38,
|
||||
],
|
||||
];
|
||||
|
||||
function concatenateHashes(hashes: Buffer[]): Buffer {
|
||||
return Buffer.concat(hashes);
|
||||
}
|
||||
function hashData(data: Buffer): string {
|
||||
const hash = crypto.createHash('sha256');
|
||||
hash.update(data);
|
||||
// return new Uint8Array(hash.digest().buffer);
|
||||
return hash.digest('hex');
|
||||
}
|
||||
|
||||
console.log(
|
||||
'concatenateHashes(dataHashes) hash:',
|
||||
hashData(concatenateHashes(dataHashesAsArray.map(hash => Buffer.from(hash)))),
|
||||
);
|
||||
|
||||
// const concat = [
|
||||
// 99, 19, -77, -51, 55, 104, 45, -42, -123, 101, -23, -79, -126, 1, 37, 89, 125,
|
||||
// -27, -117, 34, -124, -110, 28, 116, -8, -70, 63, -61, 96, -105, 26, -41, 63,
|
||||
// -22, 106, 78, 31, 16, 114, -119, -19, 17, 92, 71, -122, 47, 62, 78, -67, -23,
|
||||
// -55, -43, 53, 4, 47, -67, -55, -123, 6, 121, 34, -125, 64, -114, -120, -101,
|
||||
// 87, -112, 121, 15, -104, 127, 85, 25, -102, 80, 20, 58, 51, 75, -63, 116, -22,
|
||||
// 0, 60, 30, 29, 30, -73, -115, 72, -9, -1, -53, 100, 124, 0, -62, 104, 108,
|
||||
// -19, -10, 97, -26, 116, -58, 69, 110, 26, 87, 17, 89, 110, -57, 108, -6, 36,
|
||||
// 21, 39, 87, 110, 102, -6, -43, -82, -125, -85, -82, -66, 82, -76, -21, -34,
|
||||
// 33, 79, 50, -104, -120, -114, 35, 116, -32, 6, -14, -100, -115, -128, -9, 10,
|
||||
// 61, 98, 86, -8, 45, -49, -46, 90, -24, -81, 38, 91, -34, -46, -63, 63, -34,
|
||||
// 104, 82, 36, 41, -118, -3, 70, 15, -108, -48, -100, 45, 105, -85, -15, -61,
|
||||
// -71, 43, -39, -94, -110, -55, -34, 89, -18, 38, 76, 123, -40, 13, 52, -29, 72,
|
||||
// -11, 59, -63, -18, -90, 103, 49, 24, -92, -85, -68, -62, -59, -100, -69, -7,
|
||||
// 28, -58, 95, 69, 15, -74, 56, 54, 38,
|
||||
// ];
|
||||
|
||||
// const concatHash = crypto.createHash('sha256');
|
||||
// concatHash.update(Buffer.from(concat));
|
||||
// const concatHashBytes = new Uint8Array(concatHash.digest().buffer);
|
||||
|
||||
// console.log('concatHashBytes:', concatHashBytes);
|
||||
|
||||
const messageDigest = [
|
||||
-80, 96, 59, -43, -125, 82, 89, -8, 105, 125, 37, -79, -98, -94, -119, 43, 13,
|
||||
39, 115, 6, 59, -27, 81, 110, 49, 75, -1, -72, -101, 73, 116, 86,
|
||||
];
|
||||
|
||||
// console.log('messageDigest:', messageDigest);
|
||||
|
||||
// Convert signed bytes to unsigned
|
||||
const unsignedBytes = messageDigest.map(b => (b < 0 ? b + 256 : b));
|
||||
|
||||
// Convert to a Buffer, then to hex
|
||||
const messageDigestHex = Buffer.from(unsignedBytes).toString('hex');
|
||||
|
||||
console.log('messageDigest:', messageDigestHex);
|
||||
|
||||
// const eContent =
|
||||
// '3166301506092a864886f70d01090331080606678108010101301c06092a864886f70d010905310f170d3139313231363137323233385a302f06092a864886f70d01090431220420b0603bd5835259f8697d25b19ea2892b0d2773063be5516e314bffb89b497456';
|
||||
|
||||
// function hexToBytes(hex: string) {
|
||||
// let bytes = new Uint8Array(Math.ceil(hex.length / 2));
|
||||
// for (let i = 0; i < bytes.length; i++) {
|
||||
// bytes[i] = parseInt(hex.substr(i * 2, 2), 16);
|
||||
// }
|
||||
// return bytes;
|
||||
// }
|
||||
|
||||
// console.log('hexToBytes(eContent):', hexToBytes(eContent));
|
||||
|
||||
// const eContentUTF8 = Buffer.from(eContent, 'hex').toString('ascii');
|
||||
// console.log(eContentUTF8);
|
||||
|
||||
// 49 : TAG
|
||||
// 102 : LENGTH
|
||||
// 48... : sequence
|
||||
// 49, 102, 48, 21, 6, 9, 42, 134, 72, 134, 247, 13,
|
||||
// 1, 9, 3, 49, 8, 6, 6, 103, 129, 8, 1, 1,
|
||||
// 1, 48, 28, 6, 9, 42, 134, 72, 134, 247, 13, 1,
|
||||
// 9, 5, 49, 15, 23, 13, 49, 57, 49, 50, 49, 54,
|
||||
// 49, 55, 50, 50, 51, 56, 90, 48, 47, 6, 9, 42,
|
||||
// 134, 72, 134, 247, 13, 1, 9, 4, 49, 34, 4, 32,
|
||||
// 176, 96, 59, 213, 131, 82, 89, 248, 105, 125, 37, 177,
|
||||
// 158, 162, 137, 43, 13, 39, 115, 6, 59, 229, 81, 110,
|
||||
// 49, 75, 255, 184, 155, 73, 116, 86
|
||||
|
||||
// "1.2.840.113549.1.9.4"
|
||||
|
||||
// TAG, LGT, RFC_3369 TAG..., TAG, SEQUENCE...
|
||||
// RFC_3369_CONTENT_TYPE_OID 48, 21, 6, 9, 42, 134, 72, 134, 247, 13, 1, 9, 3, | 49, 8, 6, 6, 103, 129, 8, 1, 1, 1,
|
||||
// signing-time 48, 28, 6, 9, 42, 134, 72, 134, 247, 13, 1, 9, 5, | 49, 15, 23, 13, 49, 57, 49, 50, 49, 54, 49, 55, 50, 50, 51, 56, 90,
|
||||
// RFC_3369_MESSAGE_DIGEST_OID 48, 47, 6, 9, 42, 134, 72, 134, 247, 13, 1, 9, 4, | 49, 34, 4, 32, | 176, 96, 59, 213, 131, 82, 89, 248, 105, 125, 37, 177, 158, 162, 137, 43, 13, 39, 115, 6, 59, 229, 81, 110, 49, 75, 255, 184, 155, 73, 116, 86
|
||||
|
||||
// Donc je veux arriver au hash suivant pour les dataHashes concaténés:
|
||||
// 34, 4, 32, | 176, 96, 59, 213, 131, 82, 89, 248, 105, 125, 37, 177, 158, 162, 137, 43, 13, 39, 115, 6, 59, 229, 81, 110, 49, 75, 255, 184, 155, 73, 116, 86
|
||||
|
||||
// const dataHashes = {
|
||||
// '1': [
|
||||
// 99, 19, -77, -51, 55, 104, 45, -42, -123, 101, -23, -79, -126, 1, 37, 89,
|
||||
// 125, -27, -117, 34, -124, -110, 28, 116, -8, -70, 63, -61, 96, -105, 26,
|
||||
// -41,
|
||||
// ],
|
||||
// '2': [
|
||||
// 63, -22, 106, 78, 31, 16, 114, -119, -19, 17, 92, 71, -122, 47, 62, 78, -67,
|
||||
// -23, -55, -43, 53, 4, 47, -67, -55, -123, 6, 121, 34, -125, 64, -114,
|
||||
// ],
|
||||
// '3': [
|
||||
// -120, -101, 87, -112, 121, 15, -104, 127, 85, 25, -102, 80, 20, 58, 51, 75,
|
||||
// -63, 116, -22, 0, 60, 30, 29, 30, -73, -115, 72, -9, -1, -53, 100, 124,
|
||||
// ],
|
||||
// '11': [
|
||||
// 0, -62, 104, 108, -19, -10, 97, -26, 116, -58, 69, 110, 26, 87, 17, 89, 110,
|
||||
// -57, 108, -6, 36, 21, 39, 87, 110, 102, -6, -43, -82, -125, -85, -82,
|
||||
// ],
|
||||
// '12': [
|
||||
// -66, 82, -76, -21, -34, 33, 79, 50, -104, -120, -114, 35, 116, -32, 6, -14,
|
||||
// -100, -115, -128, -9, 10, 61, 98, 86, -8, 45, -49, -46, 90, -24, -81, 38,
|
||||
// ],
|
||||
// '13': [
|
||||
// 91, -34, -46, -63, 63, -34, 104, 82, 36, 41, -118, -3, 70, 15, -108, -48,
|
||||
// -100, 45, 105, -85, -15, -61, -71, 43, -39, -94, -110, -55, -34, 89, -18,
|
||||
// 38,
|
||||
// ],
|
||||
// '14': [
|
||||
// 76, 123, -40, 13, 52, -29, 72, -11, 59, -63, -18, -90, 103, 49, 24, -92,
|
||||
// -85, -68, -62, -59, -100, -69, -7, 28, -58, 95, 69, 15, -74, 56, 54, 38,
|
||||
// ],
|
||||
// };
|
||||
|
||||
// ContentInfo encapContentInfo = signedData.getEncapContentInfo();
|
||||
// DEROctetString eContent = (DEROctetString)encapContentInfo.getContent();
|
||||
|
||||
const signedData = {
|
||||
bodyLength: -1,
|
||||
elements: [
|
||||
{
|
||||
bodyLength: -1,
|
||||
elements: [
|
||||
{
|
||||
body: [42, -122, 72, -122, -9, 13, 1, 9, 3],
|
||||
identifier: '1.2.840.113549.1.9.3',
|
||||
},
|
||||
{
|
||||
bodyLength: -1,
|
||||
elements: [
|
||||
{body: [103, -127, 8, 1, 1, 1], identifier: '2.23.136.1.1.1'},
|
||||
],
|
||||
isSorted: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
bodyLength: -1,
|
||||
elements: [
|
||||
{
|
||||
body: [42, -122, 72, -122, -9, 13, 1, 9, 5],
|
||||
identifier: '1.2.840.113549.1.9.5',
|
||||
},
|
||||
{
|
||||
bodyLength: -1,
|
||||
elements: [
|
||||
{time: [49, 57, 49, 50, 49, 54, 49, 55, 50, 50, 51, 56, 90]},
|
||||
],
|
||||
isSorted: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
bodyLength: -1,
|
||||
elements: [
|
||||
{
|
||||
body: [42, -122, 72, -122, -9, 13, 1, 9, 4],
|
||||
identifier: '1.2.840.113549.1.9.4',
|
||||
},
|
||||
{
|
||||
bodyLength: -1,
|
||||
elements: [
|
||||
{
|
||||
string: [
|
||||
-80, 96, 59, -43, -125, 82, 89, -8, 105, 125, 37, -79, -98, -94,
|
||||
-119, 43, 13, 39, 115, 6, 59, -27, 81, 110, 49, 75, -1, -72,
|
||||
-101, 73, 116, 86,
|
||||
],
|
||||
},
|
||||
],
|
||||
isSorted: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
isSorted: false,
|
||||
};
|
||||
|
||||
// Convert the byte arrays into hex strings, and store them in an array in the correct order
|
||||
const hashHexStrings = Object.keys(dataHashes)
|
||||
.sort()
|
||||
.map(key => {
|
||||
const byteArray = dataHashes[key as keyof typeof dataHashes];
|
||||
// Convert signed bytes to unsigned, then to hex string
|
||||
const hexString = byteArray
|
||||
.map(b => (b < 0 ? b + 256 : b))
|
||||
.map(b => b.toString(16).padStart(2, '0'))
|
||||
.join('');
|
||||
return hexString;
|
||||
});
|
||||
|
||||
// Concatenate the hex strings
|
||||
const concatenatedHashesHex = hashHexStrings.join('');
|
||||
|
||||
// Hash the concatenated hashes to get the message digest in hex
|
||||
const messageDigestHex2 = hashDataHex(concatenatedHashesHex);
|
||||
|
||||
console.log('messageDigestHex2:', messageDigestHex2);
|
||||
|
||||
// Function to hash hex data
|
||||
function hashDataHex(dataHex: string): string {
|
||||
const hash = crypto.createHash('sha256');
|
||||
hash.update(dataHex, 'hex');
|
||||
return hash.digest('hex');
|
||||
}
|
||||
91
app/scripts/script3.ts
Normal file
91
app/scripts/script3.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
import * as crypto from 'crypto';
|
||||
|
||||
// On a la donnée de base :
|
||||
// Pas besoin de faire ça, on va pas prouver l'image pour l'instant
|
||||
|
||||
const dg2InSave = {
|
||||
buffer: [
|
||||
127, 41, 40, -118, 2, -112, -1, -39, -19, -19, 105, -71, -45, 50, 40, 106,
|
||||
53, -53, 70, 125, -69, 14, -50, 127, -91, -81, 110, -74, 44, -38, 92, 37,
|
||||
-8, -64, 126, -88, -84, 127, -122, -118, -65, -92, 15, 63, 28, 39, 13, 42,
|
||||
125, 54, -107, 2, -97, 100, 117, -38, 1, 27, 61, 79, -118, -104, 31, 99, 29,
|
||||
-94, 12, -16, -27, -46, -40, -127, 7, -1, 53, -90, 33, 63, 105, -33, 119,
|
||||
-81, 107, 119, -105, 48, 20, -13, -74, 112, -30, -106, 39, -10, -29, -112,
|
||||
-17, -2, 54, -9, -115, -16, 75, 104, 103, 94, 87, -60, -82, 13, 92, -16, 9,
|
||||
-38, 17, -101, -95, 125, 121, 70, -104, -120, 58, 51, -108, -125, 40, 48,
|
||||
-57, 88, -112, 95, -52, 69, 26, -62, -22, 94, -35, -104, -88, 28, 61, 87,
|
||||
-126, -60, -70, -22, 19, 122, -19, 30, -3, -109, -32, 18, -15, -3, 4, -116,
|
||||
-19, 112, -85, 121, -17, -60, -128, -28, 14, -85, -85, 0, -19, 62, 14, 95,
|
||||
63, -40, 77, -27, 6, 78, -47, 93, -33, -7, 61, -46, -126, 120, 1, 67, -38,
|
||||
74, 45, 96, 54, -67, 40, -1, -124, 33, -15, 63, -111, 119, 66, 106, -21,
|
||||
-46, -107, 75, -37, -114, 111, 48, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
],
|
||||
bufferLength: 8,
|
||||
fileLength: 13814,
|
||||
fs: {
|
||||
fidToSFI: {
|
||||
'257': 1,
|
||||
'258': 2,
|
||||
'259': 3,
|
||||
'260': 4,
|
||||
'261': 5,
|
||||
'262': 6,
|
||||
'263': 7,
|
||||
'264': 8,
|
||||
'265': 9,
|
||||
'266': 10,
|
||||
'267': 11,
|
||||
'268': 12,
|
||||
'269': 13,
|
||||
'270': 14,
|
||||
'271': 15,
|
||||
'272': 16,
|
||||
'284': 28,
|
||||
'285': 29,
|
||||
'286': 30,
|
||||
},
|
||||
fileInfos: {
|
||||
'257': [Object],
|
||||
'258': [Object],
|
||||
'270': [Object],
|
||||
'285': [Object],
|
||||
},
|
||||
isSFIEnabled: false,
|
||||
isSelected: true,
|
||||
selectedFID: 270,
|
||||
service: {secureMessagingSender: [Object], service: [Object]},
|
||||
wrapper: {
|
||||
ksEnc: [Object],
|
||||
ksMac: [Object],
|
||||
maxTranceiveLength: 256,
|
||||
shouldCheckMAC: false,
|
||||
ssc: 0,
|
||||
},
|
||||
},
|
||||
markedOffset: -1,
|
||||
offsetBufferInFile: 13806,
|
||||
offsetInBuffer: 8,
|
||||
path: [{buffer: [Object], fid: 258}],
|
||||
};
|
||||
|
||||
const photo = {
|
||||
base64:
|
||||
'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4gIoSUNDX1BST0ZJTEUAAQEAAAIYAAAAAAIQAABtbnRyUkdCIFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAAHRyWFlaAAABZAAAABRnWFlaAAABeAAAABRiWFlaAAABjAAAABRyVFJDAAABoAAAAChnVFJDAAABoAAAAChiVFJDAAABoAAAACh3dHB0AAAByAAAABRjcHJ0AAAB3AAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAFgAAAAcAHMAUgBHAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFhZWiAAAAAAAABvogAAOPUAAAOQWFlaIAAAAAAAAGKZAAC3hQAAGNpYWVogAAAAAAAAJKAAAA+EAAC2z3BhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABYWVogAAAAAAAA9tYAAQAAAADTLW1sdWMAAAAAAAAAAQAAAAxlblVTAAAAIAAAABwARwBvAG8AZwBsAGUAIABJAG4AYwAuACAAMgAwADEANv/bAEMA///////////////////////////////////////////////////////////////////////////////////////bAEMB///////////////////////////////////////////////////////////////////////////////////////AABEIAUAA8AMBIgACEQEDEQH/xAAXAAEBAQEAAAAAAAAAAAAAAAAAAQID/8QAIRABAQABAwQDAQAAAAAAAAAAAAERAhJhMYGh8CFB0VH/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAf/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/ANmRAXJlFAAAAAAAAAAAEAUQBcmUAXJlAFyIAogCiAKIAqKgCoAoAAACKgKIAAAAAAAAAAAAAAAAAAAqKAgKAigAIADFoN5kZ3MgLupuqANbqu5gB0zBzMg6DE1YbAAAAAAAAAABQQAAFEAAtc7bQW3LIAAAAAAAAALLhAHSVXJqXANhLkAAAAAABQAQFBALcAzqv0wdQAAAAAAAAAAAFBBcICyukuXNZcA2AAAACgIqAAAMar9NuYIAAAAAALhcAyq4XAMmGsAJhcKAmEsaKDCNVkG9N+mnJ0lzAUABUUBFQAAC9HJvV0YAAAFMZBMNyEigAIoKAgoCKigIqKJWHRiiI1prIDqEAAABUAABjV1Zb1MAA1AMNIoAACoCqIAoggAKAAgxW2KCAsB0nQJ0AAAUEBUAGdTC6rmoBG2Z1aBREBcmWcGAayZZUGhAVUyIIZMphcAZXKAKzWkoMrIjpOgKAAACgAIqAxq+mWtXVkFjTMaATKpATItiSAKAKqKKyKgiCpgF5MqmAVKqUEb09HN009AUAAAFAARUBnVPth0vRzoLG2I0AKAiKAigAqKKgAIoCAKAzWmaCRudGI6QAAAAFRQBFARit1kGY0z0aBQBUFAQABUUEAAVFABAGa0n2ISNsxoAAAAFAARUASxQGaLhAFQBUAUBKCjKiKMqKoAAAgDUAgAAAAAKAAigIAAipQQAAAAAEFQFEUUAAAEGmY0AAAAAACgAIqAAAAAyLUABAPkAE+RQEUAFQBQAWKAAAAAAAKAAioAAAADNv0jOfloFEABQEFAQUBAAFlRJfkHQAAAAAAAFQAAAAS3AKl6VjdUttBGpWQGxnKgqoAqACoAAiZAtQAdZ0ipLmKAAAAAAACWyAqZwxdX8QGrq/jAAAAAAAA1KrC5BpEyZBTKZQFQAAAGpq/rIDqrlLY3NQNAAAAxdX8YAAAAAAAAAAAAAAAAAAAAAAAAAFlsdJcuQDsMTV/W5cg4jrsnPvY2Tn3sDkOuyc+9jZOfH4DkOuyc+9jZOfH4DkOuyc+9jZOfewOQ67Jz72Nk597A5DrsnPj8Nk58fgOQ67Jz72Nk597A5DrsnPvY2Tnx+A5DrsnPj8Nk58fgOQ67Jz72Nk597A5DrsnPvY2Tn3sDkOuyc+9jZOfewOQ67Jz4/DZOfH4DkOuyc+Pw2Tn3sDksvy6bJz72Nk597A//Z',
|
||||
height: 320,
|
||||
width: 240,
|
||||
};
|
||||
|
||||
// On veut retrouver la version encodée. Début :
|
||||
const dg2fileEncodedStart = [
|
||||
117, -126, 53, -14, 127, 97, -126, 53, -19, 2, 1, 1, 127, 96, -126, 53, -27,
|
||||
-95, 15, -128, 2, 1, 1, -127, 1, 2, -121, 2, 1, 1, -120, 2, 0, 8, 95, 46,
|
||||
-126, 53, -49, 70, 65, 67, 0, 48, 49, 48, 0, 0, 0, 53, -49, 0, 1, 0, 0, 53,
|
||||
-63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, -16, 1, 64, 1,
|
||||
1, 0, 0, 0, 0, 0, 0, 0, 12, 10,
|
||||
];
|
||||
|
||||
const photoBytes = atob(photo.base64.split(',')[1])
|
||||
.split('')
|
||||
.map(char => char.charCodeAt(0));
|
||||
|
||||
console.log('photoBytes:', photoBytes);
|
||||
Reference in New Issue
Block a user