Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const base = require('base-x');
- const baser62 = base("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
- const min = 0x000000;
- const max = 0xffffff;
- function getRandomInt() {
- return Math.floor(Math.random() * (max - min)) + min;
- }
- class BufferOffset {
- constructor(buffer) {
- this.buffer = buffer;
- this.offset = 0;
- }
- write(length, data) {
- this.buffer.writeUIntBE(data, this.offset, length);
- this.offset += length;
- }
- }
- const buffer = Buffer.alloc(43);
- const b = new BufferOffset(buffer);
- // b.write(4, getRandomInt()); // Random
- // b.write(4, Date.now() / 1000); // Creation timestamp
- // b.write(1, 0x55); // Object type
- // b.write(1, 0x44); // Object localization
- // b.write(3, 0x333333); // Application Id
- // b.write(2, 0x1111); // Image width
- // b.write(2, 0x2222); // Image height
- // b.write(2, 0x6666); // Provider Id
- // b.write(4, 0x77777777); // Product creation timestamp
- // b.write(5, 0x8888888888); // Product random
- // b.write(3, 0x999999); // Product counter
- // b.write(4, getRandomInt()); // Original image random
- // b.write(4, Date.now() / 1000); // original image timestamp
- // b.write(2, 0x2222); // Original image width
- // b.write(2, 0x6666); // Original image height
- b.write(4, getRandomInt()); // Random
- b.write(4, Date.now() / 1000); // Creation timestamp
- b.write(1, 0x55); // Object type
- b.write(1, 0x44); // Object localization
- b.write(3, 0x333333); // Application Id
- b.write(2, 0x1111); // Image width
- b.write(2, 0x2222); // Image height
- b.write(2, 0x6666); // Provider Id
- b.write(4, 0x77777777); // Product creation timestamp
- b.write(5, 0x8888888888); // Product random
- b.write(3, 0x999999); // Product counter
- b.write(4, getRandomInt()); // Original image random
- b.write(4, Date.now() / 1000); // original image timestamp
- b.write(2, 0x2222); // Original image width
- b.write(2, 0x6666); // Original image height
- console.log(b.offset);
- console.log(buffer);
- const result = baser62.encode(buffer)
- console.log(result.length);
- console.log(result);
- // 4; Random number
- // 6; Millisecond timestamp
- // 2; Object type
- // 2; Object localization
- // 3; Application Id
- // 2; Image width
- // 2; Image height
- // 4; Random number
- // 6; Millisecond timestamp
- // 2; Object type
- // 2; Object localization
- // 3; Application Id
- // 2; Image width
- // 2; Image height
- // 2; Provider Id
- // 4; Product creation timestamp
- // 5; Product random
- // 3; Product couter
- // 4; Random number
- // 6; Millisecond timestamp
- // 2; Object type
- // 2; Object localization
- // 3; Application Id
- // 2; Image width
- // 2; Image height
- // 2; Provider Id
- // 4; Product creation timestamp
- // 5; Product random
- // 3; Product couter
- // 4; Random number
- // 6; Millisecond timestamp
- // 2; Original Image width
- // 2; Original Image height
- // 0x00 = null
- // 0x10 = null
- // 0x01 = static images created by developers
- // 0x11 = static images thumbs created by developers
- // 0x02 = static images created by client
- // 0x12 = static images thumbs by client
- // 0x03 = example products images
- // 0x13 = example products thumbs
- // 0x04 = products images
- // 0x14 = products thumbs
- // 0x15 = integrations images
- // 0x15 = integrations thumbs
- // 0x16 = integrations images
- // 0x16 = integrations thumbs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement