WPDK  1.5.0
WordPress Development Kit
 All Data Structures Files Functions Variables Pages
wpdk-crypt.php
Go to the documentation of this file.
1 <?php
13 class WPDKCrypt extends WPDKObject {
14 
22  public $__version = '0.9.1';
23 
35  public static function uniqcode( $prefix = '', $posfix = '', $max_length = 64 )
36  {
37  $uniqcode = uniqid( $prefix ) . $posfix;
38  if ( ( $uniqcode_len = strlen( $uniqcode ) ) > $max_length ) {
39  /* Catch from end */
40  return substr( $uniqcode, -$max_length );
41  }
42  return $uniqcode;
43  }
44 
55  static function randomAlphaNumber( $len = 8, $extra = '#,!,.' )
56  {
57  $alfa = '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,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';
58  $num = '0,1,2,3,4,5,6,7,8,9';
59  if ( $extra != '' ) {
60  $num .= ',' . $extra;
61  }
62  $alfa = explode( ',', $alfa );
63  $num = explode( ',', $num );
64  shuffle( $alfa );
65  shuffle( $num );
66  $misc = array_merge( $alfa, $num );
67  shuffle( $misc );
68  $result = substr( implode( '', $misc ), 0, $len );
69 
70  return $result;
71  }
72 }