- Joined
- Nov 16, 2009
- Messages
- 866
- Reaction score
- 580
Hi,
I made a two way encryption system to store credit cards securely. It can be used to encrypt everything but is made for credit cards. Alot is to confuse the hell out of a potential hacker and avoid decryption. It has 3 encoding layers and 2 encryption layers plus the structure is also confusing as seven heaven. The salt is stored in the final result but even with the encryption salt it's hard to decode it. I calculated that it's around 1: Quadrillion chance to crack it, so pretty secure. It can also encrypt arrays (converts to JSON).
The only downside right now is that it increases the string size by 400x (400%)
What do you guys think?
Script:
Example of a credit card encrypted:
I made a two way encryption system to store credit cards securely. It can be used to encrypt everything but is made for credit cards. Alot is to confuse the hell out of a potential hacker and avoid decryption. It has 3 encoding layers and 2 encryption layers plus the structure is also confusing as seven heaven. The salt is stored in the final result but even with the encryption salt it's hard to decode it. I calculated that it's around 1: Quadrillion chance to crack it, so pretty secure. It can also encrypt arrays (converts to JSON).
The only downside right now is that it increases the string size by 400x (400%)
What do you guys think?
Script:
You must be registered to see links
PHP:
<?php
class CCProtect {
private function pekkaEncode($s) {
$out = '';
for ($i=0;$i<strlen($s); $i++) {
$out .= sprintf("%03d", ord($s[$i]));
}
return $out;
}
private function pekkaDecode($s) {
$out = '';
for ($i=0;$i<strlen($s);$i+=3) {
$out .= chr($s[$i].$s[$i+1].$s[$i+2]);
}
return $out;
}
private function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';
for($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomString;
}
private function mCrypt($text, $salt) {
return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($salt), $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
}
private function mDecrypt($text, $salt) {
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($salt), base64_decode($text), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)));
}
public function encrypt($content) {
$response = array(
0 => rand(1000, 9999),
1 => rand(1000, 9999),
2 => rand(1000, 9999),
3 => rand(1000, 9999),
4 => rand(1000, 9999),
5 => rand(1000, 9999),
6 => rand(1000, 9999),
7 => rand(1000, 9999),
8 => rand(1000, 9999),
9 => rand(1000, 9999),
10 => rand(0, 9),
11 => rand(0, 9),
12 => rand(0, 9),
13 => rand(0, 9),
14 => rand(5, 9),
15 => '',
16 => '',
17 => '',
18 => '',
19 => '',
20 => '',
21 => '',
22 => '',
23 => '',
24 => '',
25 => '',
);
$rand = rand(10, 14);
$combination = str_split($response[$response[$rand]], 1);
$password = $response[$combination[0]] . $response[$combination[1]] . $response[$combination[2]] . $response[$combination[3]];
if(is_array($content)) {
$content = json_encode($content);
}
$content_length = strlen($content);
$content_field = rand(20, 25);
$store_content_field = 10 + $response[14];
for($i=15; $i <= 19; $i++) {
if($i == $store_content_field) {
$response[$i] = $this->mCrypt($content_field, $password);
} else {
$response[$i] = $this->mCrypt(rand(10, 99), $password);
}
}
for($i=20; $i <= 25; $i++) {
if($i == $content_field) {
$response[$i] = $this->mCrypt($content, $password);
} else {
$response[$i] = $this->mCrypt($this->generateRandomString($content_length), $password);
}
}
$json = json_encode($response);
$string = $password . $this->pekkaEncode(str_rot13(convert_uuencode($json)));
$string = str_split($string, 4);
$string = implode(' ', $string);
return trim($string);
}
public function decrypt($string) {
$string = str_replace(' ', '', $string);
$password = substr($string, 0, 16);
$decoded = json_decode(convert_uudecode(str_rot13($this->pekkaDecode(substr($string, 16)))));
return trim($this->mDecrypt($decoded[$this->mDecrypt($decoded[10 + $decoded[14]], $password)], $password));
}
}
$protection = new CCProtect;
$cc = array(
'firstname' => 'Krista',
'lastname' => 'Sheppard',
'dob' => 'August 11, 1932',
'cardnumber' => '4916 5210 7061 9044',
'cvv2' => '769',
'expire' => array(
'month' => '6',
'year' => '2015',
),
);
echo chunk_split($protection->encrypt($cc), 75);
Example of a credit card encrypted:
Code:
7650 7650 5508 9101 0900 5407 0052 0720 4403 5064 0890 4505 1044 0710 4603
4067 0700 4505 1096 0710 4303 5081 0750 4605 1048 0890 4505 1044 0750 4403
4067 0740 4508 0052 0670 4303 5060 0710 4503 5052 0890 4405 1040 0720 4406
9067 0760 4405 1096 0680 1009 0043 0350 5607 2045 0510 8108 9044 0340 6707
1043 0350 9608 9045 0500 6707 4043 0340 4007 2062 0520 9206 8046 0510 5303
5052 0830 8208 1056 0830 9308 6060 0350 8204 5057 0700 4107 1062 0340 9005
5060 0510 8205 1060 0740 6105 5010 0900 6208 3049 0740 5808 2056 0700 4903
8093 0460 4507 4040 0730 5305 3067 0660 4805 1071 0790 4303 4041 0510 5205
1060 0720 5808 1093 0370 4808 0061 0410 5307 1082 0400 5408 0061 0540 5607
4049 0650 5007 4045 0420 4508 3076 0840 1009 0060 0530 3703 8044 0390 6108
9056 0710 4007 1048 0520 7207 5056 0510 5708 0051 0530 4503 7047 0500 4008
9040 0840 3307 6045 0520 9308 2057 0380 5708 9054 0820 4508 1060 0520 9308
0051 0840 4807 0051 0540 6107 2048 0530 5303 3010 0900 5108 1093 0700 5703
6086 0520 4805 1033 0800 5308 1064 0730 5705 1041 0810 6108 3045 0400 5907
2036 0930 4007 9067 0790 5108 1060 0760 6005 1037 0550 4808 2082 0810 5208
4057 0710 6007 1057 0680 4507 2081 0740 5607 3086 0350 1009 0050 0540 8107
0054 0360 7806 0043 0700 4906 9051 0370 6706 6057 0810 8603 8061 0730 4508
3057 0810 6006 9057 0700 6007 1047 0500 4008 9040 0820 4507 2048 0540 8204
0053 0720 5308 5052 0720 4408 8045 0830 4007 4057 0390 8603 6010 0900 5807
1037 0340 4505 1041 0880 6107 2037 0820 6205 2049 0510 4408 2082 0330 5905
1049 0440 5605 5052 0880 5805 5053 0860 5105 2071 0930 4007 9067 0790 4407
3053 0780 5703 6076 0500 5803 7064 0740 5105 1045 0380 4805 4041 0690 1009
0044 0540 4503 8050 0820 5305 5052 0550 6108 0044 0350 7806 5054 0820 5703
5060 0820 8207 0056 0520 7107 6061 0710 7204 0051 0360 4007 5061 0530 3304
9060 0390 3706 5053 0840 5307 7059 0830 7207 0061 0830 6804 2051 0360 9308
4010 0900 4403 8064 0700 5608 3041 0810 6105 2090 0370 5703 6082 0850 4603
6089 0730 5307 2053 0500 5203 6053 0730 5007 1061 0370 4507 3053 0520 5108
2045 0880 4207 2086 0350 6107 0053 0790 5105 1033 0740 4408 0060 0680 4207
1060 0720 1009 0050 0550 3308 0060 0840 8204 2046 0360 9207 4060 0720 3709
0059 0710 6103 6050 0390 6105 4046 0540 6804 9044 0810 4108 3054 0520 8607
9052 0830 8604 9060 0520 6407 5052 0730 7205 6059 0540 7205 4051 0360 8603
3056 0740 4106 7010 0900 6103 5056 0880 4405 1033 0820 5007 2037 0890 5708
3057 0860 4507 2037 0780 5807 1072 0880 4907 1057 0760 4503 6076 0820 6205
2089 0670 4808 2057 0870 5707 2061 0440 5005 5082 0780 5908 2037 0330 5408
1037 0900 5407 9090 0410 1009 0059 0360 4508 0059 0720 6706 6049 0710 7604
9054 0360 7206 6044 0740 5607 2062 0800 3308 7059 0810 3609 3047 0500 4008
9040 0820 3706 9061 0390 4105 4053 0830 8506 9044 0520 4903 4048 0540 7106
7062 0830 7805 8045 0530 5304 5010 0900 4405 3049 0800 5005 2093 0860 5305
2041 0880 4808 4086 0420 5208 1061 0660 4907 4057 0860 4908 4086 0780 4403
6061 0700 4603 6049 0860 5605 2092 0710 5103 9033 0750 4207 2033 0760 5405
5053 0760 5703 9056 0760 5607 2052 0680 1009 0052 0510 4906 0043 0720 4906
9060 0360 8605 5057 0740 4908 3058 0820 4105 8060 0520 9303 6062 0390 7804
5045 0370 8205 8059 0700 5305 6055 0340 9304 8056 0730 4103 9053 0840 5707
7044 0520 4905 2050 0710 9308 8059 0800 5607 0010 0900 5003 6082 0520 5105
1052 0750 4507 0037 0900 5705 5086 0340 5003 5045 0740 6007 3048 0710 6105
4072 0360 4903 8093 0460 4507 3061 0430 4603 6085 0750 4907 4057 0450 5608
4045 0500 6105 4093 0380 4503 7048 0740 5905 3057 0850 1009 0061 0520 3706
7058 0380 4807 2057 0810 7806 8053 0730 6103 4058 0730 6007 3051 0510 8106
7056 0730 7208 8050 0380 9307 8044 0540 4907 8059 0360 6805 6056 0800 4906
0043 0710 9003 8052 0530 4108 8049 0380 5207 2052 0510 5305 4010 0900 5208
1049 0530 4403 8036 0740 5807 1093 0660 5108 4082 0360 5205 1081 0710 4503
6036 0930 4705 0040 0890 4008 3037 0480 6008 0081 0690 4603 8052 0680 4505
2045 0480 4605 1045 0880 5207 2078 0680 6008 2061 0760 5805 2057 0750 1009
0053 0720 4108 6044 0380 4105 5049 0710 5705 2045 0340 8906 7045 0720 8107
4055 0340 9304 8052 0550 4908 7061 0530 8207 1051 0830 9303 6057 0830 5303
4059 0350 3708 6058 0370 4508 5050 0700 3305 5051 0530 6105 1060 0830 6808
3010 0900 5208 0041 0890 5908 4078 0580 4805 5037 0850 5503 4093 0460 5703
7033 0790 4605 5045 0840 5805 1061 0550 5907 4086 0780 5008 2033 0870 4905
4078 0740 5203 8068 0810 5008 4078 0730 5605 2053 0760 5107 0045 0660 4207
1076 0330 1009 0044 0370 3704 6060 0530 8206 0043 0710 8607 3053 0830 4904
5056 0510 4508 0058 0730 9308 7053 0810 3704 3051 0540 4508 7053 0800 5607
6044 0700 8204 4054 0540 6108 0058 0520 7807 2056 0820 7807 3059 0510 7805
2049 0720 4407 3010 0900 5305 5082 0660 4403 5033 0560 4903 6064 0750 6203
8072 0790 6208 3041 0790 5503 4092 0670 5605 4045 0700 4508 3053 0490 5307
3061 0820 4907 3061 0680 6103 9096 0740 5305 2085 0690 5908 4057 0530 4505
1056 0730 5808 1053 0450 1009 0051 0700 9607 4053 0520 6107 3045 0380 9007
9044 0520 4807 4046 0350 3708 4047 0510 7107 9043 0340 4007 4050 0510 7808
8050 0810 4503 9061 0830 7608 0044 0710 9007 8045 0530 8607 7045 0810 6106
8057 0740 5305 7052 0550 4108 6010 0900 4503 6049 0330 6103 8068 0350 5503
4093 0420 6203 5037 0450 4805 4053 0360 4507 2033 0760 6108 3072 0530 4805
1078 0600 4307 1053 0400 5707 2082 0730 5708 1090 0680 5008 3057 0380 4907
0049 0360 5305 5037 0830 4605 2052 0680 1009 0051 0740 5206 8051 0810 9008
0054 0830 7608 7053 0820 6706 6045 0810 8608 1055 0340 9307 0057 0820 8607
1062 0550 5703 4048 0830 7604 0045 0810 9004 9059 0820 8206 5045 0820 4907
2060 0810 9005 0058 0530 6103 3045 0540 3606 8010 0900 6105 2075 0730 4508
4053 0680 5403 8089 0700 4508 1078 0480 6103 6090 0790 5605 4037 0330 6005
2072 0550 5203 8037 0470 5903 5041 0670 5003 9037 0380 5705 3056 0880 6105
4090 0540 4508 4052 0740 5503 4093 0540 5605 1049 0850 1009 0050 0820 7807
8052 0520 7808 1057 0370 4507 4060 0360 4504 9050 0390 4407 6053 0390 5307
7058 0380 6103 6058 0830 7208 0060 0840 8205 2045 0520 8605 8046 0360 8608
8052 0700 7805 4058 0510 4507 3058 0520 7807 1046 0520 7606 5010 0900 6208
0049 0840 6005 3041 0800 4405 1041 0770 6005 4093 0420 5805 3036 0930 4705
0040 0890 4008 1072 0470 4507 1078 0760 5003 8068 0450 5203 8044 0670 4605
3041 0400 4905 4045 0880 5907 4033 0900 5703 6041 0770 4907 2082 0580 1009
0044 0520 7208 2056 0520 8203 8046 0550 4905 7046 0350 6104 9049 0370 8204
1054 0530 7808 7051 0520 6007 3061 0740 4107 3060 0810 4507 1062 0520 4107
4049 0360 9005 0057 0360 4506 7057 0550 8603 3049 0710 7605 8060 0390 5705
1010 0900 5805 2041 0660 4807 2033 0850 4903 6078 0690 5903 9061 0730 4605
2082 0500 4905 3053 0520 5903 8045 0770 6103 7052 0740 5008 2045 0770 5405
4064 0750 6205 1078 0420 5705 2057 0550 4505 4045 0450 5003 6068 0430 5408
0057 0890 1009 0048 0830 5304 1051 0810 9004 3044 0550 4505 6053 0840 5207
4052 0550 3706 7060 0820 3704 5058 0510 4006 7053 0730 4505 3051 0830 6103
7044 0730 7605 1044 0740 8206 7060 0810 7606 9044 0710 5607 2056 0800 6106
9060 0530 8205 2010 0900 4907 0064 0720 5405 2078 0340 5705 4093 0400 4808
4041 0740 5908 3044 0750 5908 3068 0860 5408 4033 0730 4603 5033 0670 5005
2082 0900 5108 3057 0810 4508 0057 0680 4903 6072 0360 5607 4078 0880 6205
5078 0650 5903 9041 0340 1009 0053 0710 7608 6054 0370 4108 8057 0390 6009
3047 0500 4008 9040 0840 4006 9057 0370 3305 1050 0710 8107 6049 0820 6107
8051 0840 7803 6054 0800 3704 8044 0530 7805 6053 0360 5707 4044 0390 9607
5057 0380 8203 8061 0360 6103 6010 0900 5703 9086 0880 4907 3078 0420 5303
6090 0900 5105 5041 0370 4403 6040 0750 4603 5061 0880 5008 4086 0430 5903
6078 0410 4807 2036 0670 5203 8076 0900 4808 1090 0770 4405 1057 0700 4908
3049 0510 4903 5049 0690 5503 4093 0870 1009 0051 0740 3307 2049 0370 8107
5052 0510 8206 9057 0520 9004 2056 0840 4506 7055 0340 9308 1049 0810 9006
5061 0800 4903 6057 0390 3703 6054 0820 3707 7052 0740 6106 0043 0730 8604
5053 0810 7604 6062 0820 8204 9048 0820 8603 8010 0900 5007 3041 0810 4908
0082 0900 6105 5041 0330 5605 5053 0500 5705 4057 0820 6103 6072 0870 5408
3076 0390 6203 6076 0710 6007 3082 0890 5807 3049 0350 5107 1056 0760 4605
3057 0490 4605 5053 0400 5008 2041 0690 5503 4093 0560 1009 0053 0730 3705
8056 0730 7606 9051 0540 4504 0051 0540 5708 6048 0710 3707 4056 0710 5307
7053 0360 4903 5054 0360 8206 6053 0810 6803 3046 0360 5703 6051 0520 4908
0051 0800 8205 4056 0700 3704 7062 0800 3703 7049 0720 8606 8010 0420 5708
2086 0380 4605 5037 0740 4705 1071 0790 5504 8096 0960 1009 6010
Last edited: