Groovy web console

subscribe to the feed Subscribe
to this
site

nexts cookies

Published 2 months ago by nico
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import java.util.*;
public class HelloWorld{
 public String generateNextEcookieValue(String cookie) {
  byte[] seed = getEcookieSeed(cookie);
  UUID nextCookie = UUID.nameUUIDFromBytes(seed);
  return nextCookie.toString() + "-" + System.currentTimeMillis();
	}

	private byte[] getEcookieSeed(String cookie) {
  String constSeed = "device-es-la-posta";
  byte[] constSeedBytes = constSeed.getBytes();
  byte[] variableSeedBytes = cookie.subSequence(0,36).toString().getBytes();
  byte[] seed = concatenateArrayBytes(constSeedBytes, variableSeedBytes);
  return seed;
	}

     private byte[] concatenateArrayBytes(byte[] one, byte[] two) {
        
        byte[] combined = new byte[one.length + two.length];
        
        System.arraycopy(one,0,combined,0         ,one.length);
        System.arraycopy(two,0,combined,one.length,two.length);

  return combined;
	}
	
     public static void main(String []args){
         
         HelloWorld helloWorld = new HelloWorld();
         //String cookie = UUID.randomUUID().toString();
         String cookie = "ab5c601c-ee53-4fc5-b255-fb59e6282814-1612307678681";
         System.out.println("Cookie: " + cookie);
         String nextCookie = helloWorld.generateNextEcookieValue(cookie);
         System.out.println("Next cookie: " + nextCookie);
         String nextnextCookie = helloWorld.generateNextEcookieValue(nextCookie);
         System.out.println("2 cookie: " + nextnextCookie);
        String nextnextnextCookie = helloWorld.generateNextEcookieValue(nextnextCookie);
         System.out.println("3 cookie: " + nextnextnextCookie);
         String nextnextnextnextCookie = helloWorld.generateNextEcookieValue(nextnextnextCookie);
         System.out.println("4 cookie: " + nextnextnextnextCookie);
        String nextnextnextnextnextCookie = helloWorld.generateNextEcookieValue(nextnextnextnextCookie);
         System.out.println("5 cookie: " + nextnextnextnextnextCookie);
        String nextnextnextnextnextnextCookie = helloWorld.generateNextEcookieValue(nextnextnextnextnextCookie);
         System.out.println("6 cookie: " + nextnextnextnextnextnextCookie);
                 String sieteCookie = helloWorld.generateNextEcookieValue(nextnextnextnextnextnextCookie);
         System.out.println("7 cookie: " + sieteCookie);
                          String ochoCookie = helloWorld.generateNextEcookieValue(sieteCookie);
         System.out.println("8 cookie: " + ochoCookie);

	
     }
}