Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Product Code

Status
Not open for further replies.

Brianfree

Programmer
Feb 6, 2008
220
0
0
GB
Hi, i have a php page which displays the following...

Product_Group_ID (2 Digits)
Reference Number (6 Digits)
Price

An example...

01
096544
12.50

I want to turn this information in to a unique secret product code that the average person couldn't decode and that i can put into my 3of 9 barcode to then decode into the right fields in access 2007 once scanned in???

Please can anyone advise???

Many thanks,

Brian
 
sure.

try this

Code:
<?php
class encrypter{
	
	public function __construct(){
		$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
		$this->iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
		$this->cypher = MCRYPT_RIJNDAEL_256;
		$this->mode = MCRYPT_MODE_ECB;
		$this->key = 'i am a very secret key';
	}
	public function encrypt($productID, $ref, $price){
		$data = serialize(array($productID, $ref, $price));
		$crypttext = mcrypt_encrypt($this->cypher, $this->key, $data, $this->mode, $this->iv);
    	return $crypttext;
	}
	
	public function decrypt($string){
		 $result = mcrypt_decrypt ( $this->cypher , $this->key , $string , $this->mode, $this->iv );
		 return unserialize($result);
	}
}

$encrypter = new encrypter;
$encryptedString = $encrypter->encrypt('productID', 'Reference', 'PRICE');
echo 'My encryption looks like this ' . $encryptedString;
echo '<br/>The Data, once decryped, looks like this: <pre>' . print_r($encrypter->decrypt($encryptedString), true) .  '</pre>';
?>
 
is 3of9 still limited to 8 characters ? (might be totaly wrong on that, it's been a while since i did barcodes)
 
good question. i took the question simply to be about encryption, knowing nothing about barcodes myself.

if barcodes are limited to certain trivial data sets or character sets then the OP might be better served by generating a unique value that corresponds to the barcode specification and then storing that unique value with the the data (s)he wishes to 'encrypt'. the data would then be totally hidden in that it is meaningless to anyone that does not have access to the OP's lookup tables.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top