ExtBasic 11

Learn how to do code review

Re: ExtBasic 11

Post by a1756 on Mon Nov 14, 2011 3:59 pm
([msg=62916]see Re: ExtBasic 11[/msg])

Hi

I don't really understand how to determine how many times i should multiply the "power of two-number" (the "power of two" i use starts with 2 and ends with 8).

The original hash by itself is an eaven number that can be divided by two which results in a number that can't be divided by any of the primes.

When adding the "power of two" with the result of the previous division, i still can't divide with any of the primes.

When multiplying the "power of two-number" with 2 and adding the result of the previous division, i can divide with many of the primes. Does this mean that the password conatins all the letters these primes represent?

[Edit: Ahh, i get it now...]
a1756
New User
New User
 
Posts: 1
Joined: Mon Nov 14, 2011 3:57 pm
Blog: View Blog (0)


Re: ExtBasic 11

Post by ZyrgEr on Thu Oct 04, 2012 4:03 am
([msg=69899]see Re: ExtBasic 11[/msg])

okay this one was quite difficult. Thanks for the 2nd powers tip! Helped a lot!
ZyrgEr
New User
New User
 
Posts: 8
Joined: Tue Sep 11, 2012 9:41 am
Blog: View Blog (0)


Re: ExtBasic 11

Post by ChronosX on Fri Jan 11, 2013 9:43 pm
([msg=72216]see Re: ExtBasic 11[/msg])

Cool mission, definitely not simple like the others. Spent about 2 hours thinking my script didn't work with my test values and then realized it was just due to a hash collision. :oops: Python is really nice for this due to it's excellent handling of large numbers.
ChronosX
New User
New User
 
Posts: 8
Joined: Mon Dec 20, 2010 4:31 pm
Blog: View Blog (0)


Re: ExtBasic 11

Post by Kremlin on Thu Apr 25, 2013 3:04 pm
([msg=75379]see Re: ExtBasic 11[/msg])

i had a ton of fun with this challenge. took me 2 days!

i wrote a little java program to help me out, but for the sake of fun, i've left out an important variable you'll have to find on your own. it takes input, either in the form of a number or a password, and returns the comparison. good luck! pm me if you need any help.

Code: Select all
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;

public class extbasic11 {
   
   static int[] primes = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101};
   static char[] chars  = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
   private static Scanner s;
   
   private static final long MAGIC_NUMBER = /*i'll never tell!*/;
   
   public static void main(String[] a) {
      
      s = new Scanner(System.in);
      System.out.print("attempt: ");
      String in = s.next();
      System.out.print("\n");
      
      if(in.matches("[a-z]*")) {
         int val = 1;
         
         for(char check : in.toCharArray())
            val *= primes[Arrays.binarySearch(chars, check)];
         
         System.out.print("return: " + val + "\n");
         
         int diff = 32 - ("" + Integer.toBinaryString(val)).length();
         
         System.out.print("result: ");
         
         for(int i = 0; i < diff; i++)
            System.out.print("0");
         
         System.out.print(Integer.toBinaryString(val) + "\n");
         System.out.println("target: 00" + Integer.toBinaryString((int)MAGIC_NUMBER) + "\n");
         
         main(null);
      } else if(in.matches("[0-9]*")) {
         
         if(in.length() > 18) {
            System.out.println("too long!\n");
            main(null);
         }
         
         int val = (int)Long.parseLong(in);
         boolean primecheck = true;
         
         for(int pcheck : getPrimeFactors(Long.parseLong(in)))
            if(pcheck > 101)
               primecheck = false;
         
         if(primecheck) {
            System.out.print("return: ");
            for(int pcheck : getPrimeFactors(Long.parseLong(in)))
               System.out.print(chars[Arrays.binarySearch(primes, pcheck)]);
            System.out.print("\n");
         } else
            System.out.println("return: cannot translate to password");
         
         int diff = 32 - ("" + Integer.toBinaryString(val)).length();
         
         System.out.print("result: ");
         
         for(int i = 0; i < diff; i++)
            System.out.print("0");
         
         System.out.print(Integer.toBinaryString(val) + "\n");
         System.out.println("target: 00" + Integer.toBinaryString((int)MAGIC_NUMBER) + "\n");
         
         main(null);
      } else
         System.exit(0);
   }
   
   public static ArrayList<Integer> getPrimeFactors(long n) {
      
      ArrayList<Integer> ret = new ArrayList<Integer>();
      
      if(n==1)
         ret.add(102);
      
      while(n%2 == 0) {
         ret.add(2);
         n = n/2;
      }
      
      for(int i = 3; i <= Math.sqrt(n); i = i+2) {
         while(n%i == 0) {
            ret.add(i);
            n = n/i;
         }
      }
      
      if(n>2)
         ret.add((int)n);

      return ret;
   }
}
Kremlin
New User
New User
 
Posts: 2
Joined: Tue Apr 23, 2013 6:43 pm
Blog: View Blog (0)


Re: ExtBasic 11

Post by K105h4r on Wed Jul 31, 2013 6:40 pm
([msg=76706]see Re: ExtBasic 11[/msg])

Hello all! I read every post on this thread and I guess I'm the only one who even don't know how to start. This is due to not knowing batch scripting. I looked over and over the code and I don't get some things:
1) Why CURRENTPOSITION increments by 3? (CURRENTPOSITION +=3)
2) PASSWORDVALUE*=!PRIME:~%CURRENTPOSITION%,3! - Same thing here; is this "3" after ',' an offset or what?
Anyway, is this algorithm suppose to assign prime number to every letter of alphabet (a=2, b=3, c=5) respectively or mixed?
Thanks in advance!

EDIT: Although I haven't found out answers on these questions, I managed to program in C some reversing algorithm. I can't check if the password is correct since it's 4071 characters long :D Can I PM someone with code to check it?
Also I don't get it why someone can get password 1000 chars long and someone 4071 like me. I understand why they will be correct, but how can computer calculate differently? Are algorithms really that different?
Sorry for a long post. Thanks!
K105h4r
New User
New User
 
Posts: 5
Joined: Wed Jul 31, 2013 1:28 pm
Blog: View Blog (0)


Previous

Return to Extended Basics

Who is online

Users browsing this forum: No registered users and 0 guests

cron