Lock Picking 101 Forum
A community dedicated to the fun and ethical hobby of lock picking.
       

Lock Picking 101 Home
Login
Profile
Members
Forum Rules
Frequent Forum Questions
SEARCH
View New Posts
View Active Topics


Live Chat on Discord
LP101 Forum Chat
Keypicking Forum Chat
Reddit r/lockpicking Chat



Learn How to Pick Locks
FAQs & General Questions
Got Beginner Questions?
Pick-Fu [Intermediate Level]


Ask a Locksmith
This Old Lock
This Old Safe
What Lock Should I Buy?



Hardware
Locks
Lock Patents
Lock Picks
Lock Bumping
Lock Impressioning
Lock Pick Guns, Snappers
European Locks & Picks
The Machine Shop
The Open Source Lock
Handcuffs


Member Spotlight
Member Introductions
Member Lock Collections
Member Social Media


Off Topic
General Chatter
Other Puzzles


Locksmith Business Info
Training & Licensing
Running a Business
Keyways & Key Blanks
Key Machines
Master Keyed Systems
Closers and Crash Bars
Life Safety Compliance
Electronic Locks & Access
Locksmith Supplies
Locksmith Lounge


Buy Sell Trade
Buy - Sell - Trade
It came from Ebay!


Advanced Topics
Membership Information
Special Access Required:
High Security Locks
Vending Locks
Advanced Lock Pick Tools
Bypass Techniques
Safes & Safe Locks
Automotive Entry & Tools
Advanced Buy/Sell/Trade


Locksport Groups
Locksport Local
Chapter President's Office
Locksport Board Room
 

random bitting generator for keys

Having read the FAQ's you are still unfulfilled and seek more enlightenment, so post your general lock picking questions here.
Forum rules
Do not post safe related questions in this sub forum! Post them in This Old Safe

The sub forum you are currently in is for asking Beginner Hobby Lock Picking questions only.

random bitting generator for keys

Postby cledry » 31 Dec 2012 0:04

One of my accounts requires us to generate totally random keys in groups of 12 each week or two. I am wondering if there is a little freeware application that could create such a random number, bearing in mind I would need to limit the 5 digits to 1-6 and couldn't have a 6 appear next to a 1 ideally. I would like to spit out say a few hundred numbers at a time. The keys do not need to follow any parity.
Jim
User avatar
cledry
 
Posts: 2836
Joined: 7 Mar 2009 23:29
Location: Orlando

Re: random bitting generator for keys

Postby easy-e » 31 Dec 2012 1:53

If you can't find a program I could write one for you pretty easily. I'm assuming any bitting that isn't key retaining would need to be thrown out too?
easy-e
 
Posts: 117
Joined: 19 Dec 2012 15:13
Location: Seattle, WA

Re: random bitting generator for keys

Postby Legion303 » 31 Dec 2012 3:11

Here's a quick and dirty bash script if you have linux or unix somewhere:

Code: Select all
#!/bin/bash

for row in `seq 1 10`; do               #10 rows
  for key in `seq 1 12`; do             #12 keys per row
    pos[0]=$((RANDOM%6+1))              #random bitting 1-6 in 1st position

    echo -n ${pos[0]}                   #print bitting of 1st position

    for i in `seq 1 4`; do              #add 4 more bittings to this key
      pos[$i]=$((RANDOM%6+1))
      current=${pos[$i]}                #current bitting
      prev=${pos[$i-1]}                 #previous bitting

      if [ "$current" = "$prev" ]       #better randomization--if two
        then pos[$i]=$((RANDOM%6+1))    #same bittings, this re-randomizes
      fi                                #one of them.

      if [ `expr "$prev" % 5` = "1" ]   #matches both 1 and 6
        then pos[$i]=$((RANDOM%4+2))    #(if prev is 1 or 6, this ensures
      fi                                #next can only be 2 through 5).

      echo -n ${pos[$i]}                #print out remaining bittings
                                        #for this key.
    done                                #next i
    echo -n " "                         #prints space between keys
  done                                  #next key
  echo
done                                    #next row


And here is some sample output:

legion@neutronstar:~$ ./bitting.sh
65462 56552 53143 42565 34631 25133 62435 46552 21456 51214 35356 44536
65145 65432 24131 63523 24346 35412 64363 65156 63521 52232 12415 45136
23512 41514 25434 24214 52642 15263 41262 62415 36546 14154 34134 54536
34154 35326 62146 25412 62621 25652 32532 62426 65123 64623 14634 45342
51563 36423 43414 41421 45454 12324 15254 14235 52536 26321 45145 63465
54565 13154 53546 62635 63143 42645 35134 26251 65341 56315 63242 56564
54565 52352 25152 54135 54125 13256 51563 53514 62313 65412 32134 53652
54521 65546 56351 15635 35464 21341 65451 42546 26431 42415 22142 33651
12152 43546 53241 51324 62364 23435 35362 46265 62364 36426 54214 15212
46523 25263 41315 53645 51341 53635 51214 54413 36252 21536 52363 13142

EDIT: cleaned up code a little and added a 10-row wrapper, so each run will give you 120 random keys. 1 and 6 will never appear next to each other, and duplicate position bittings (i.e., 11, 22, etc.) should be fairly rare.

-steve
User avatar
Legion303
 
Posts: 2343
Joined: 6 May 2006 6:52
Location: Denver, CO

Re: random bitting generator for keys

Postby cledry » 1 Jan 2013 22:56

Any bad combinations, such as descending order or 6 in the first position I could weed out manually. Don't have Linux unfortunately on the machines at work, but that is exactly what I need. A little Javascript program would work though.

Ideally 6 wouldn't appear next to 1 and 6 would not be in the first position.
Jim
User avatar
cledry
 
Posts: 2836
Joined: 7 Mar 2009 23:29
Location: Orlando

Re: random bitting generator for keys

Postby cledry » 1 Jan 2013 22:58

easy-e wrote:If you can't find a program I could write one for you pretty easily. I'm assuming any bitting that isn't key retaining would need to be thrown out too?


Haven't found one yet, but it might be a nice little project.
Jim
User avatar
cledry
 
Posts: 2836
Joined: 7 Mar 2009 23:29
Location: Orlando

Re: random bitting generator for keys

Postby Ambro » 1 Jan 2013 23:17

I'd be more than happy to write you a windows application in VS 2012 .NET - C# that does this tomorrow when I'm at my workstation.

If this needs to be multiplatform, as previously mentioned, it would be best written using a java with a frontend gui.

Either way, let me know!
Ambro
 
Posts: 7
Joined: 1 Jan 2013 2:09
Location: Los Angeles, California, USA

Re: random bitting generator for keys

Postby lockr » 2 Jan 2013 0:22

As much as I love shell scripting (i'm also a Unix guy), I figured just for fun i'd take a few minutes and translate the above code into PHP:

Code: Select all
<?php

$pins=6;   // number of pins
$min=1;      // min pin size
$max=6;      // max pin size
$total=100;   // number of combinations to generate

$keys=array();
for ($ln=$k=0;$k<$total;$k++) {
   do {
      $bits='';
      for ($b=0;$b<$pins;$b++)
         $bits.=mt_rand($min,$max);
      for ($i=1;$i<$pins;$i++) {
         if ($bits[$i]==$bits[$i-1])
            $bits[$i]=mt_rand($min,$max);
            if (($bits[$i-1]==$min || $bits[$i-1]==$max) &&
               ($bits[$i]==$min || $bits[$i]==$max))
                  $bits[$i]=mt_rand($min+1,$max-1);
         }
   } while (@$keys[$bits]);
   $keys[$bits]=1;
   print $bits.' ';
   if (++$ln%10==0) print "\n";
}

?>


This code goes one step further and ensures that no key code is duplicated throughout the entire batch.

You can play with it live here: http://www.sc2.ca/locks/generate/

enjoy..!
lockr
 
Posts: 105
Joined: 3 Oct 2012 10:25
Location: BC, Canada

Re: random bitting generator for keys

Postby femurat » 2 Jan 2013 6:05

Well done lockr. Nothing can be easier than clicking on a link.

Cheers :)
User avatar
femurat
Site Admin
 
Posts: 3745
Joined: 22 Sep 2008 9:06
Location: Italy

Re: random bitting generator for keys

Postby minifhncc » 3 Jan 2013 10:09

cledry wrote:6 would not be in the first position

Does that actually make the key weaker? What about a code like 66436?

It seems common that key manufacturers here at least seem to avoid cutting keys on the deepest cut, abeit, I actually seen in master keyed systems where the first cut was the deepest.

It seems reasonable then that if one was to prevent having the same key as someone else then they should try and utilise the deepest cuts appropriately, doesn't it?
minifhncc
 
Posts: 284
Joined: 10 Jun 2011 23:03

Re: random bitting generator for keys

Postby shatar » 3 Jan 2013 15:11

lockr wrote:As much as I love shell scripting (i'm also a Unix guy), I figured just for fun i'd take a few minutes and translate the above code into PHP:

<<Snip>>

enjoy..!


that is really cool.
i am thinking about getting the ultimate challenge lock.
i guess i could use that table and teach someone like my sister how to repin that and the i could pick the lock without knowing which pinning is in the lock. :D
shatar
 
Posts: 16
Joined: 13 Dec 2012 19:35

Re: random bitting generator for keys

Postby lockr » 4 Jan 2013 2:13

femurat wrote:Well done lockr. Nothing can be easier than clicking on a link.


Thanks! I felt the inclination to build it as a fun project because I really don't do as much coding as I used to; these days I have to come up with make-work projects to keep myself in shape =)

In all fairness it wouldn't be all that difficult to build something substantially more sophisticated, if there were a need for it. Thoughts?
lockr
 
Posts: 105
Joined: 3 Oct 2012 10:25
Location: BC, Canada

Re: random bitting generator for keys

Postby Legion303 » 4 Jan 2013 6:46

lockr wrote:Thoughts?


Add a mailer function so he can send bittings to the client. :)

-steve
User avatar
Legion303
 
Posts: 2343
Joined: 6 May 2006 6:52
Location: Denver, CO

Re: random bitting generator for keys

Postby FarmerFreak » 4 Jan 2013 9:18

Until you find a program. You could always roll a six sided die and re-roll any problem numbers.
FarmerFreak
 
Posts: 737
Joined: 21 Apr 2009 11:58
Location: SLC, Utah

Re: random bitting generator for keys

Postby cledry » 12 Jan 2013 22:54

minifhncc wrote:
cledry wrote:6 would not be in the first position

Does that actually make the key weaker? What about a code like 66436?

It seems common that key manufacturers here at least seem to avoid cutting keys on the deepest cut, abeit, I actually seen in master keyed systems where the first cut was the deepest.

It seems reasonable then that if one was to prevent having the same key as someone else then they should try and utilise the deepest cuts appropriately, doesn't it?


Yes, of course it makes the key weaker. It is good practice to avoid the deepest cut and often the second deepest cut in the first position. I've been doing this for a long time and when keys with deep cuts break it is almost always ones with a deep cut at the shoulder.

As for MK systems I would choose wisely. For example if you have 0-9 in your bitting choices then I would choose an even cut in the first, at least I would know the 9 wouldn't be used, although an 8 might come up depending on the size of the system.
Jim
User avatar
cledry
 
Posts: 2836
Joined: 7 Mar 2009 23:29
Location: Orlando

Re: random bitting generator for keys

Postby cledry » 12 Jan 2013 23:04

That works great. Thanks very much.

lockr wrote:As much as I love shell scripting (i'm also a Unix guy), I figured just for fun i'd take a few minutes and translate the above code into PHP:

Code: Select all
<?php

$pins=6;   // number of pins
$min=1;      // min pin size
$max=6;      // max pin size
$total=100;   // number of combinations to generate

$keys=array();
for ($ln=$k=0;$k<$total;$k++) {
   do {
      $bits='';
      for ($b=0;$b<$pins;$b++)
         $bits.=mt_rand($min,$max);
      for ($i=1;$i<$pins;$i++) {
         if ($bits[$i]==$bits[$i-1])
            $bits[$i]=mt_rand($min,$max);
            if (($bits[$i-1]==$min || $bits[$i-1]==$max) &&
               ($bits[$i]==$min || $bits[$i]==$max))
                  $bits[$i]=mt_rand($min+1,$max-1);
         }
   } while (@$keys[$bits]);
   $keys[$bits]=1;
   print $bits.' ';
   if (++$ln%10==0) print "\n";
}

?>


This code goes one step further and ensures that no key code is duplicated throughout the entire batch.

You can play with it live here: http://www.sc2.ca/locks/generate/

enjoy..!
Jim
User avatar
cledry
 
Posts: 2836
Joined: 7 Mar 2009 23:29
Location: Orlando

Next

Return to Got Questions? - Ask Beginner Hobby Lockpicking Questions Here

Who is online

Users browsing this forum: No registered users and 9 guests